@Test public void testPeek() throws Exception { subject.add("cows"); subject.add("sheep"); subject.add("ducks"); subject.add("mice"); subject.add("dogs"); subject.add("cats"); subject.add("birds"); int size = subject.size(); Assert.assertEquals(7, size); String animal = subject.peek(); Assert.assertEquals("cows", animal); size = subject.size(); Assert.assertEquals(7, size); }
@Test public void testClear() throws Exception { subject.add("cows"); subject.add("sheep"); subject.add("ducks"); subject.add("mice"); subject.add("dogs"); subject.add("cats"); subject.add("birds"); subject.clear(); int size = subject.size(); Assert.assertEquals(0, size); subject.add("birds"); size = subject.size(); Assert.assertEquals(1, size); }
@Test public void testToArray() throws Exception { subject.add("cows"); subject.add("sheep"); subject.add("ducks"); subject.add("mice"); subject.add("dogs"); subject.add("cats"); subject.add("birds"); int size = subject.size(); Assert.assertEquals(7, size); Object[] animals = subject.toArray(); Assert.assertEquals(7, animals.length); }
@Test public void testPoll() throws Exception { subject.add("cows"); subject.add("sheep"); subject.add("ducks"); subject.add("mice"); subject.add("dogs"); subject.add("cats"); subject.add("birds"); int size = subject.size(); Assert.assertEquals(7, size); String animal = subject.poll(); Assert.assertEquals("cows", animal); size = subject.size(); Assert.assertEquals(6, size); animal = subject.poll(); Assert.assertEquals("sheep", animal); size = subject.size(); Assert.assertEquals(5, size); animal = subject.poll(); Assert.assertEquals("ducks", animal); size = subject.size(); Assert.assertEquals(4, size); animal = subject.poll(); Assert.assertEquals("mice", animal); size = subject.size(); Assert.assertEquals(3, size); animal = subject.poll(); Assert.assertEquals("dogs", animal); size = subject.size(); Assert.assertEquals(2, size); animal = subject.poll(); Assert.assertEquals("cats", animal); size = subject.size(); Assert.assertEquals(1, size); animal = subject.poll(); Assert.assertEquals("birds", animal); size = subject.size(); Assert.assertEquals(0, size); animal = subject.poll(); Assert.assertEquals(null, animal); }
@Test(expected = NoSuchElementException.class) public void testRemove() throws Exception { subject.add("cows"); subject.add("sheep"); subject.add("ducks"); subject.add("mice"); subject.add("dogs"); subject.add("cats"); subject.add("birds"); int size = subject.size(); Assert.assertEquals(7, size); String animal = subject.remove(); Assert.assertEquals("cows", animal); size = subject.size(); Assert.assertEquals(6, size); animal = subject.remove(); Assert.assertEquals("sheep", animal); size = subject.size(); Assert.assertEquals(5, size); animal = subject.remove(); Assert.assertEquals("ducks", animal); size = subject.size(); Assert.assertEquals(4, size); animal = subject.remove(); Assert.assertEquals("mice", animal); size = subject.size(); Assert.assertEquals(3, size); animal = subject.remove(); Assert.assertEquals("dogs", animal); size = subject.size(); Assert.assertEquals(2, size); animal = subject.remove(); Assert.assertEquals("cats", animal); size = subject.size(); Assert.assertEquals(1, size); animal = subject.remove(); Assert.assertEquals("birds", animal); size = subject.size(); Assert.assertEquals(0, size); animal = subject.remove(); }