Test of get method, of class SimpleList.
()
| 43 | * Test of get method, of class SimpleList. |
| 44 | */ |
| 45 | @Test |
| 46 | public void testGet() |
| 47 | { |
| 48 | System.out.println("get"); |
| 49 | SimpleList instance = new SimpleList(); |
| 50 | try |
| 51 | { |
| 52 | Object obj = instance.get(0); |
| 53 | fail("Should not have been able to obtain " + obj); |
| 54 | } |
| 55 | catch(Exception ex) |
| 56 | { |
| 57 | |
| 58 | } |
| 59 | instance.add("a"); |
| 60 | instance.add("b"); |
| 61 | assertEquals("a", instance.get(0)); |
| 62 | assertEquals("b", instance.get(1)); |
| 63 | |
| 64 | assertEquals("a", instance.remove(0)); |
| 65 | |
| 66 | assertEquals("b", instance.get(0)); |
| 67 | try |
| 68 | { |
| 69 | Object obj = instance.get(1); |
| 70 | fail("Should not have been able to obtain " + obj); |
| 71 | } |
| 72 | catch(Exception ex) |
| 73 | { |
| 74 | |
| 75 | } |
| 76 | instance.add("c"); |
| 77 | instance.add("d"); |
| 78 | |
| 79 | assertEquals("b", instance.get(0)); |
| 80 | assertEquals("c", instance.get(1)); |
| 81 | assertEquals("d", instance.get(2)); |
| 82 | try |
| 83 | { |
| 84 | Object obj = instance.get(3); |
| 85 | fail("Should not have been able to obtain " + obj); |
| 86 | } |
| 87 | catch(Exception ex) |
| 88 | { |
| 89 | |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Test of size method, of class SimpleList. |