Test of set method, of class SimpleList.
()
| 126 | * Test of set method, of class SimpleList. |
| 127 | */ |
| 128 | @Test |
| 129 | public void testSet() |
| 130 | { |
| 131 | System.out.println("set"); |
| 132 | SimpleList<String> instance = new SimpleList<String>(); |
| 133 | try |
| 134 | { |
| 135 | Object obj = instance.get(0); |
| 136 | fail("Should not have been able to obtain " + obj); |
| 137 | } |
| 138 | catch(Exception ex) |
| 139 | { |
| 140 | |
| 141 | } |
| 142 | instance.add("A"); |
| 143 | instance.add("B"); |
| 144 | instance.set(0, instance.get(0).toLowerCase()); |
| 145 | instance.set(1, instance.get(1).toLowerCase()); |
| 146 | assertEquals("a", instance.get(0)); |
| 147 | assertEquals("b", instance.get(1)); |
| 148 | |
| 149 | assertEquals("a", instance.remove(0)); |
| 150 | |
| 151 | assertEquals("b", instance.get(0)); |
| 152 | try |
| 153 | { |
| 154 | Object obj = instance.get(1); |
| 155 | fail("Should not have been able to obtain " + obj); |
| 156 | } |
| 157 | catch(Exception ex) |
| 158 | { |
| 159 | |
| 160 | } |
| 161 | instance.add("C"); |
| 162 | instance.add("D"); |
| 163 | |
| 164 | instance.set(1, instance.get(1).toLowerCase()); |
| 165 | instance.set(2, instance.get(2).toLowerCase()); |
| 166 | assertEquals("b", instance.get(0)); |
| 167 | assertEquals("c", instance.get(1)); |
| 168 | assertEquals("d", instance.get(2)); |
| 169 | try |
| 170 | { |
| 171 | Object obj = instance.get(3); |
| 172 | fail("Should not have been able to obtain " + obj); |
| 173 | } |
| 174 | catch(Exception ex) |
| 175 | { |
| 176 | |
| 177 | } |
| 178 | } |
| 179 | } |