Anyone? J unit test cases

profilecompSci
priorityqueuetest.java

import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; /** * PriorityQueueTest tests the priority queue. * @author tai-lanhirabayashi * */ public class PriorityQueueTest { PriorityQueue p; /** * setUp initializes the test */ @SuppressWarnings("unchecked") @Before public void setUp(){ p=new PriorityQueue(PriorityQueue.PriorityType.HIGH_VALUE_PRIORITY); p.add("zero",0); p.add("one",1); p.add("two",2); p.add("three",3); p.add("four",4); p.add("five",5); System.out.println("this is the tree: "+ ((obj) p.q.h[0]).getPriority() + " " + ((obj) p.q.h[1]).getPriority()+" "+((obj) p.q.h[2]).getPriority()+ " " + ((obj) p.q.h[3]).getPriority()+ " " + ((obj) p.q.h[4]).getPriority()+ " " + ((obj) p.q.h[5]).getPriority()); } /** * tests the getFirst() function */ // @Test public void testGetFirst() { obj a = (obj) p.getFirst(); assertEquals(5, a.getPriority()); } /** * tests the getPriority function */ @Test public void testGetPriority() { obj a= (obj) p.getFirst(); assertEquals(5, a.getPriority()); p.remove(); p.remove(); p.remove(); p.remove(); p.remove(); a=(obj) p.getFirst(); assertEquals(0, a.getPriority()); } /** * tests the is empty function */ @Test public void testIsEmpty() { assertFalse(p.isEmpty()); p.remove(); p.remove(); p.remove(); p.remove(); p.remove(); p.remove(); assertTrue(p.isEmpty()); } /** * tests the remove function */ @Test public void testRemove() { p.remove(); obj a= (obj) p.getFirst(); assertEquals(4,a.getPriority()); p.remove(); p.remove(); p.remove(); p.remove(); p.remove(); assertEquals(null, p.remove()); } /** * tests the size function */ @Test public void testSize() { assertEquals(6,p.size()); p.remove(); assertEquals(5,p.size()); p.remove(); assertEquals(4,p.size()); p.remove(); p.remove(); p.remove(); p.remove(); assertEquals(0,p.size()); } @Test @SuppressWarnings({ "unchecked", "rawtypes" }) public void testLow(){ p=new PriorityQueue(PriorityQueue.PriorityType.LOW_VALUE_PRIORITY); p.add("zero", 0); p.add("one", 1); p.add("negative one", -1); p.add("2", 2); assertEquals(-1, p.getPriority()); } }