()
| 301 | } |
| 302 | |
| 303 | public void testPutAll() { |
| 304 | Map m = new BinaryTree(); |
| 305 | LocalTestNode nodes[] = makeLocalNodes(); |
| 306 | |
| 307 | for (int k = 0; k < nodes.length; k++) |
| 308 | { |
| 309 | m.put(nodes[ k ].getKey(), nodes[ k ]); |
| 310 | } |
| 311 | Map m1 = new HashMap(); |
| 312 | |
| 313 | m1.put(null, "foo"); |
| 314 | try |
| 315 | { |
| 316 | m.putAll(m1); |
| 317 | fail("Should have caught NullPointerException"); |
| 318 | } |
| 319 | catch (NullPointerException ignored) |
| 320 | { |
| 321 | } |
| 322 | m1 = new HashMap(); |
| 323 | m1.put(new Object(), "bar"); |
| 324 | try |
| 325 | { |
| 326 | m.putAll(m1); |
| 327 | fail("Should have caught ClassCastException"); |
| 328 | } |
| 329 | catch (ClassCastException ignored) |
| 330 | { |
| 331 | } |
| 332 | m1 = new HashMap(); |
| 333 | m1.put("fubar", null); |
| 334 | try |
| 335 | { |
| 336 | m.putAll(m1); |
| 337 | fail("Should have caught NullPointerException"); |
| 338 | } |
| 339 | catch (NullPointerException ignored) |
| 340 | { |
| 341 | } |
| 342 | m1 = new HashMap(); |
| 343 | m1.put("fubar", new Object()); |
| 344 | try |
| 345 | { |
| 346 | m.putAll(m1); |
| 347 | fail("Should have caught ClassCastException"); |
| 348 | } |
| 349 | catch (ClassCastException ignored) |
| 350 | { |
| 351 | } |
| 352 | assertEquals(nodes.length, m.size()); |
| 353 | m = new BinaryTree(); |
| 354 | m1 = new HashMap(); |
| 355 | for (int k = 0; k < nodes.length; k++) |
| 356 | { |
| 357 | m1.put(nodes[ k ].getKey(), nodes[ k ].getValue()); |
| 358 | } |
| 359 | m.putAll(m1); |
| 360 | assertEquals(nodes.length, m.size()); |
nothing calls this directly
no test coverage detected