Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
306
306lab3
Commits
8f44858c
Commit
8f44858c
authored
Apr 08, 2019
by
michael lundquist
Browse files
Adding tests. This was a requirement for assignment 6.
parent
456644bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
thirdlab/src/test/java/com/ds/thirdlab/AppTest.java
View file @
8f44858c
...
...
@@ -12,7 +12,59 @@ public class AppTest {
* Rigorous Test.
*/
@Test
public
void
testApp
()
{
assertTrue
(
true
);
public
void
testAddRemove
()
{
UnsortedPriorityQueue
pq
=
new
UnsortedPriorityQueue
();
addPlanes
(
pq
);
assertTrue
(
pq
.
size
()
==
9
);
//
removePlanes
(
pq
);
assertTrue
(
pq
.
size
()
==
0
);
//
}
}
/**
* Adds 9 planes in reverse order
*
* @param pq
*/
public
void
addPlanes
(
UnsortedPriorityQueue
pq
)
{
Flight
flight
;
pq
.
add
(
new
Flight
(
"test no period"
,
true
));
for
(
int
i
=
8
;
i
>
0
;
i
--)
{
flight
=
new
Flight
(
"test "
+
i
,
true
);
flight
.
setConnectionPeriod
(
1
);
pq
.
add
(
flight
);
}
}
/**
* The test version
*
*/
@Test
public
void
orderedRemovePlanesTest
()
{
UnsortedPriorityQueue
pq
=
new
UnsortedPriorityQueue
();
addPlanes
(
pq
);
PQEntry
min
=
pq
.
removeMin
();
PQEntry
next_min
=
pq
.
removeMin
();
;
while
(
pq
.
size
()
>=
1
)
{
assertTrue
(
min
.
getKey
()
<=
next_min
.
getKey
());
min
=
next_min
;
next_min
=
pq
.
removeMin
();
}
}
/**
* The non-test version
*
* @param pq
*/
public
void
removePlanes
(
UnsortedPriorityQueue
pq
)
{
PQEntry
min
=
pq
.
removeMin
();
PQEntry
next_min
=
pq
.
removeMin
();
;
while
(
pq
.
size
()
>=
1
)
{
min
=
next_min
;
next_min
=
pq
.
removeMin
();
}
}
}
\ No newline at end of file
thirdlab/src/test/java/com/ds/thirdlab/HomeSuiteHome.java
0 → 100644
View file @
8f44858c
package
com.ds.thirdlab
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite.SuiteClasses
;
import
org.junit.runners.Suite
;
/**
* Unit test for simple App.
*
* @author <a href="mailto:mlundqu2@masonlive.gmu.edu">Michael Lundquist</a>
* Gnumber: G00737340
*/
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
AppTest
.
class
})
public
class
HomeSuiteHome
{
}
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