1 32 package net.sf.retrotranslator.runtime.java.util; 33 34 import java.util.*; 35 import junit.framework.TestCase; 36 37 40 public class _LinkedListTestCase extends TestCase { 41 42 LinkedList list = new LinkedList(); 43 44 protected void setUp() throws Exception { 45 super.setUp(); 46 list.add("a"); 47 list.add("b"); 48 } 49 50 public void testElement() throws Exception { 51 assertEquals("a", list.element()); 52 } 53 54 public void testOffer() throws Exception { 55 assertTrue(list.offer("c")); 56 assertEquals("c", list.getLast()); 57 } 58 59 public void testPeek() throws Exception { 60 assertEquals("a", list.peek()); 61 list.clear(); 62 assertNull(list.peek()); 63 } 64 65 public void testPoll() throws Exception { 66 assertEquals("a", list.poll()); 67 assertEquals("b", list.getFirst()); 68 assertEquals(1, list.size()); 69 list.clear(); 70 assertNull(list.poll()); 71 } 72 73 public void testRemove() throws Exception { 74 assertEquals("a", list.remove()); 75 assertEquals("b", list.getFirst()); 76 assertEquals(1, list.size()); 77 list.clear(); 78 try { 79 list.remove(); 80 fail(); 81 } catch (NoSuchElementException e) { 82 } 84 } 85 } | Popular Tags |