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