@Test public void testCaseWithSameScore() throws Exception { Data data1 = new Data(10, 5.5f); ListNode node1 = new ListNode(data1); Data data2 = new Data(10, 5.6f); ListNode node2 = new ListNode(data2); Data data3 = new Data(8, 4.5f); ListNode node3 = new ListNode(data3); Data data4 = new Data(8, 3.5f); ListNode node4 = new ListNode(data4); Data data5 = new Data(10, 5.7f); ListNode node5 = new ListNode(data5); Data data6 = new Data(8, 4.0f); ListNode node6 = new ListNode(data6); SortedList sortedList = new SortedList(new ScoreComparator(), new SubScoreComparator()); sortedList.insert(node1); sortedList.insert(node2); sortedList.insert(node3); sortedList.insert(node4); sortedList.insert(node5); sortedList.insert(node6); Assert.assertEquals(new Integer(8), sortedList.getMin().getData().getScore()); Assert.assertEquals(new Float(3.5), sortedList.getMin().getData().getSubScore()); Assert.assertEquals(6, sortedList.getSize()); sortedList.removeMin(); Assert.assertEquals(new Integer(8), sortedList.getMin().getData().getScore()); Assert.assertEquals(new Float(4.0), sortedList.getMin().getData().getSubScore()); Assert.assertEquals(5, sortedList.getSize()); }
@Test public void testSimpleCase() throws Exception { Data data1 = new Data(10, 5.5f); ListNode node1 = new ListNode(data1); Data data2 = new Data(11, 5.6f); ListNode node2 = new ListNode(data2); Data data3 = new Data(8, 4.5f); ListNode node3 = new ListNode(data3); SortedList sortedList = new SortedList(new ScoreComparator(), new SubScoreComparator()); sortedList.insert(node1); sortedList.insert(node2); sortedList.insert(node3); Assert.assertEquals(new Integer(8), sortedList.getMin().getData().getScore()); Assert.assertEquals(3, sortedList.getSize()); sortedList.removeMin(); Assert.assertEquals(new Integer(10), sortedList.getMin().getData().getScore()); Assert.assertEquals(2, sortedList.getSize()); }