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.48 by jsr166, Sun Jul 17 03:40:07 2016 UTC vs.
Revision 1.54 by jsr166, Sat Mar 18 20:42:20 2017 UTC

# Line 32 | Line 32 | public class ConcurrentHashMapTest exten
32       * Returns a new map from Integers 1-5 to Strings "A"-"E".
33       */
34      private static ConcurrentHashMap<Integer, String> map5() {
35 <        ConcurrentHashMap map = new ConcurrentHashMap<Integer, String>(5);
35 >        ConcurrentHashMap<Integer, String> map = new ConcurrentHashMap<>(5);
36          assertTrue(map.isEmpty());
37          map.put(one, "A");
38          map.put(two, "B");
# Line 119 | Line 119 | public class ConcurrentHashMapTest exten
119          ConcurrentHashMap<BI, Boolean> m =
120              new ConcurrentHashMap<BI, Boolean>();
121          for (int i = 0; i < size; i++) {
122 <            assertTrue(m.put(new CI(i), true) == null);
122 >            assertNull(m.put(new CI(i), true));
123          }
124          for (int i = 0; i < size; i++) {
125              assertTrue(m.containsKey(new CI(i)));
# Line 140 | Line 140 | public class ConcurrentHashMapTest exten
140              BS bs = new BS(String.valueOf(i));
141              LexicographicList<BI> bis = new LexicographicList<BI>(bi);
142              LexicographicList<BS> bss = new LexicographicList<BS>(bs);
143 <            assertTrue(m.putIfAbsent(bis, true) == null);
143 >            assertNull(m.putIfAbsent(bis, true));
144              assertTrue(m.containsKey(bis));
145              if (m.putIfAbsent(bss, true) == null)
146                  assertTrue(m.containsKey(bss));
# Line 331 | Line 331 | public class ConcurrentHashMapTest exten
331      }
332  
333      /**
334 +     * Test keySet().removeAll on empty map
335 +     */
336 +    public void testKeySet_empty_removeAll() {
337 +        ConcurrentHashMap<Integer, String> map = new ConcurrentHashMap<>();
338 +        Set<Integer> set = map.keySet();
339 +        set.removeAll(Collections.emptyList());
340 +        assertTrue(map.isEmpty());
341 +        assertTrue(set.isEmpty());
342 +        // following is test for JDK-8163353
343 +        set.removeAll(Collections.emptySet());
344 +        assertTrue(map.isEmpty());
345 +        assertTrue(set.isEmpty());
346 +    }
347 +
348 +    /**
349       * keySet.toArray returns contains all keys
350       */
351      public void testKeySetToArray() {
# Line 808 | Line 823 | public class ConcurrentHashMapTest exten
823       * ant -Djsr166.tckTestClass=ConcurrentHashMapTest -Djsr166.methodFilter=testRemoveAll_performance -Djsr166.expensiveTests=true tck
824       */
825      public void testRemoveAll_performance() {
826 <        int mapSize = expensiveTests ? 1_000_000 : 100;
827 <        int iterations = expensiveTests ? 500 : 2;
828 <        ConcurrentHashMap<Integer, Integer> map = new ConcurrentHashMap<>();
826 >        final int mapSize = expensiveTests ? 1_000_000 : 100;
827 >        final int iterations = expensiveTests ? 500 : 2;
828 >        final ConcurrentHashMap<Integer, Integer> map = new ConcurrentHashMap<>();
829          for (int i = 0; i < mapSize; i++)
830              map.put(i, i);
831          Set<Integer> keySet = map.keySet();
# Line 819 | Line 834 | public class ConcurrentHashMapTest exten
834              assertFalse(keySet.removeAll(removeMe));
835          assertEquals(mapSize, map.size());
836      }
837 +
838   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines