384 equal(c instanceof RandomAccess,
385 clone instanceof RandomAccess);
386 if ((c instanceof List) || (c instanceof Set))
387 equal(c, clone);
388 else
389 equal(new HashSet<Integer>(c),
390 new HashSet<Integer>(serialClone(c)));
391 } catch (Error xxx) {
392 if (! (xxx.getCause() instanceof NotSerializableException))
393 throw xxx;
394 }
395 }
396 }
397 catch (Throwable t) { unexpected(t); }
398 }
399
400 //----------------------------------------------------------------
401 // If add(null) succeeds, contains(null) & remove(null) should succeed
402 //----------------------------------------------------------------
403 private static void testNullElement(Collection<Integer> c) {
404 // !!!! 5018849: (coll) TreeSet.contains(null) does not agree with Javadoc
405 if (c instanceof TreeSet) return;
406
407 try {
408 check(c.add(null));
409 if (c.size() == 1)
410 equal(c.toString(), "[null]");
411 try {
412 checkFunctionalInvariants(c);
413 check(c.contains(null));
414 check(c.remove(null));
415 }
416 catch (Throwable t) { unexpected(t); }
417 }
418 catch (NullPointerException e) { /* OK */ }
419 catch (Throwable t) { unexpected(t); }
420 }
421
422
423 //----------------------------------------------------------------
424 // If add("x") succeeds, contains("x") & remove("x") should succeed
425 //----------------------------------------------------------------
|
384 equal(c instanceof RandomAccess,
385 clone instanceof RandomAccess);
386 if ((c instanceof List) || (c instanceof Set))
387 equal(c, clone);
388 else
389 equal(new HashSet<Integer>(c),
390 new HashSet<Integer>(serialClone(c)));
391 } catch (Error xxx) {
392 if (! (xxx.getCause() instanceof NotSerializableException))
393 throw xxx;
394 }
395 }
396 }
397 catch (Throwable t) { unexpected(t); }
398 }
399
400 //----------------------------------------------------------------
401 // If add(null) succeeds, contains(null) & remove(null) should succeed
402 //----------------------------------------------------------------
403 private static void testNullElement(Collection<Integer> c) {
404
405 try {
406 check(c.add(null));
407 if (c.size() == 1)
408 equal(c.toString(), "[null]");
409 try {
410 checkFunctionalInvariants(c);
411 check(c.contains(null));
412 check(c.remove(null));
413 }
414 catch (Throwable t) { unexpected(t); }
415 }
416 catch (NullPointerException e) { /* OK */ }
417 catch (Throwable t) { unexpected(t); }
418 }
419
420
421 //----------------------------------------------------------------
422 // If add("x") succeeds, contains("x") & remove("x") should succeed
423 //----------------------------------------------------------------
|