Commit 8f44858c authored by michael lundquist's avatar michael lundquist
Browse files

Adding tests. This was a requirement for assignment 6.

parent 456644bd
......@@ -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
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 {
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment