ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ConcurrentHashMapTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ConcurrentHashMapTest.java (file contents):
Revision 1.44 by jsr166, Sat Feb 28 18:27:31 2015 UTC vs.
Revision 1.48 by jsr166, Sun Jul 17 03:40:07 2016 UTC

# Line 22 | Line 22 | import junit.framework.TestSuite;
22  
23   public class ConcurrentHashMapTest extends JSR166TestCase {
24      public static void main(String[] args) {
25 <        junit.textui.TestRunner.run(suite());
25 >        main(suite(), args);
26      }
27      public static Test suite() {
28          return new TestSuite(ConcurrentHashMapTest.class);
# Line 45 | Line 45 | public class ConcurrentHashMapTest exten
45      }
46  
47      /** Re-implement Integer.compare for old java versions */
48 <    static int compare(int x, int y) { return x < y ? -1 : x > y ? 1 : 0; }
48 >    static int compare(int x, int y) {
49 >        return (x < y) ? -1 : (x > y) ? 1 : 0;
50 >    }
51  
52      // classes for testing Comparable fallbacks
53      static class BI implements Comparable<BI> {
# Line 533 | Line 535 | public class ConcurrentHashMapTest exten
535      /**
536       * Constructor (initialCapacity, loadFactor) throws
537       * IllegalArgumentException if either argument is negative
538 <      */
538 >     */
539      public void testConstructor2() {
540          try {
541              new ConcurrentHashMap(-1, .75f);
# Line 801 | Line 803 | public class ConcurrentHashMapTest exten
803          }
804      }
805  
806 +    /**
807 +     * Tests performance of removeAll when the other collection is much smaller.
808 +     * ant -Djsr166.tckTestClass=ConcurrentHashMapTest -Djsr166.methodFilter=testRemoveAll_performance -Djsr166.expensiveTests=true tck
809 +     */
810 +    public void testRemoveAll_performance() {
811 +        int mapSize = expensiveTests ? 1_000_000 : 100;
812 +        int iterations = expensiveTests ? 500 : 2;
813 +        ConcurrentHashMap<Integer, Integer> map = new ConcurrentHashMap<>();
814 +        for (int i = 0; i < mapSize; i++)
815 +            map.put(i, i);
816 +        Set<Integer> keySet = map.keySet();
817 +        Collection<Integer> removeMe = Arrays.asList(new Integer[] { -99, -86 });
818 +        for (int i = 0; i < iterations; i++)
819 +            assertFalse(keySet.removeAll(removeMe));
820 +        assertEquals(mapSize, map.size());
821 +    }
822   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines