Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs2-23wi
project06
Commits
b74013c0
Commit
b74013c0
authored
2 years ago
by
Snigdha Saha
Browse files
Options
Download
Email Patches
Plain Diff
more thorough program testing
parent
c5c884a5
master
No related merge requests found
Pipeline
#78459
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/edu/caltech/cs2/project06/ProgramTests.java
+6
-5
tests/edu/caltech/cs2/project06/ProgramTests.java
with
6 additions
and
5 deletions
+6
-5
tests/edu/caltech/cs2/project06/ProgramTests.java
View file @
b74013c0
...
...
@@ -84,14 +84,14 @@ public class ProgramTests {
return
new
Program
(
program
);
}
private
void
testProgram
(
Program
program
,
int
maxColors
)
{
private
void
testProgram
(
Program
program
,
Program
controlProgram
,
int
maxColors
)
{
NodeGraph
interference
=
program
.
constructInterferenceGraph
();
DSatur
.
color
(
interference
);
Program
modified
=
program
.
color
(
interference
.
getColoring
());
assertTrue
(
modified
.
variables
().
size
()
<=
maxColors
,
"Interference graph coloring uses more colors than expected "
+
"(ie: more variables were connected by edges than expected)."
);
assertIterableEquals
(
interpret
(
p
rogram
),
interpret
(
modified
),
"Interference graph does not validly "
assertIterableEquals
(
interpret
(
controlP
rogram
),
interpret
(
modified
),
"Interference graph does not validly "
+
" reflect interferences (ie: the resulting program overwrites its own variables)."
);
}
...
...
@@ -99,14 +99,14 @@ public class ProgramTests {
@Tag
(
"A"
)
@DisplayName
(
"Test on 8-instruction program"
)
public
void
testProgram1
()
{
testProgram
(
program1
(),
3
);
testProgram
(
program1
(),
program1
(),
3
);
}
@Test
@Tag
(
"A"
)
@DisplayName
(
"Test on 10-instruction program"
)
public
void
testProgram2
(){
testProgram
(
program2
(),
3
);
testProgram
(
program2
(),
program2
(),
3
);
}
@Test
...
...
@@ -116,7 +116,8 @@ public class ProgramTests {
List
<
Integer
>
answers
=
List
.
of
(
2
,
5
,
2
,
3
,
3
,
3
,
2
,
1
,
4
,
3
,
2
,
3
,
3
,
4
,
2
,
2
,
4
,
2
,
3
,
2
,
2
,
4
,
2
,
2
,
3
,
3
,
3
,
2
,
4
,
3
,
4
,
3
,
2
,
1
,
4
,
2
,
2
,
4
,
3
,
4
,
2
,
5
,
3
,
2
,
3
,
3
,
3
,
3
,
3
,
1
,
3
,
2
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
2
,
1
,
2
,
2
,
2
,
2
,
2
,
3
,
2
,
2
,
3
,
3
,
3
,
2
,
2
,
3
,
2
,
2
,
4
,
2
,
4
,
3
,
3
,
2
,
3
,
4
,
1
,
2
,
3
,
2
,
3
,
1
,
3
,
3
,
3
,
2
,
2
,
2
,
3
,
2
,
3
,
4
,
2
,
4
,
4
,
4
,
3
,
5
,
3
,
5
,
2
,
3
,
2
,
2
,
3
,
2
,
4
,
2
,
4
,
2
,
2
,
3
,
4
,
2
,
3
,
3
,
3
,
4
,
3
,
3
,
3
,
4
,
3
,
2
,
3
,
2
,
3
,
4
,
3
,
3
,
3
,
4
,
3
,
3
,
3
,
2
,
2
,
3
,
2
);
for
(
int
seed
=
1
;
seed
<
150
;
seed
++)
{
Program
p
=
programGen
(
15
,
seed
);
testProgram
(
p
,
answers
.
get
(
seed
-
1
));
Program
cP
=
programGen
(
15
,
seed
);
testProgram
(
p
,
cP
,
answers
.
get
(
seed
-
1
));
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help