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

Comparing jsr166/src/test/tck/ConcurrentSkipListMapTest.java (file contents):
Revision 1.25 by jsr166, Tue May 31 16:16:23 2011 UTC vs.
Revision 1.37 by jsr166, Sun May 24 01:23:17 2015 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import junit.framework.*;
8 < import java.util.*;
7 > import java.util.ArrayList;
8 > import java.util.Arrays;
9 > import java.util.BitSet;
10 > import java.util.Collection;
11 > import java.util.Iterator;
12 > import java.util.Map;
13 > import java.util.NavigableMap;
14 > import java.util.NavigableSet;
15 > import java.util.NoSuchElementException;
16 > import java.util.Random;
17 > import java.util.Set;
18   import java.util.concurrent.ConcurrentSkipListMap;
19  
20 + import junit.framework.Test;
21 + import junit.framework.TestSuite;
22 +
23   public class ConcurrentSkipListMapTest 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(ConcurrentSkipListMapTest.class);
29      }
30  
31      /**
32 <     * Create a map from Integers 1-5 to Strings "A"-"E".
32 >     * Returns a new map from Integers 1-5 to Strings "A"-"E".
33       */
34      private static ConcurrentSkipListMap map5() {
35          ConcurrentSkipListMap map = new ConcurrentSkipListMap();
# Line 38 | Line 50 | public class ConcurrentSkipListMapTest e
50      public void testClear() {
51          ConcurrentSkipListMap map = map5();
52          map.clear();
53 <        assertEquals(map.size(), 0);
53 >        assertEquals(0, map.size());
54      }
55  
56      /**
57 <     *
57 >     * copy constructor creates map equal to source map
58       */
59      public void testConstructFromSorted() {
60          ConcurrentSkipListMap map = map5();
# Line 174 | Line 186 | public class ConcurrentSkipListMapTest e
186              last = k;
187              ++count;
188          }
189 <        assertEquals(count ,5);
189 >        assertEquals(5, count);
190      }
191  
192      /**
# Line 193 | Line 205 | public class ConcurrentSkipListMapTest e
205              last = k;
206              ++count;
207          }
208 <        assertEquals(count ,5);
208 >        assertEquals(5, count);
209      }
210  
211      /**
# Line 212 | Line 224 | public class ConcurrentSkipListMapTest e
224              last = k;
225              ++count;
226          }
227 <        assertEquals(count, 5);
227 >        assertEquals(5, count);
228      }
229  
230      /**
# Line 231 | Line 243 | public class ConcurrentSkipListMapTest e
243              last = k;
244              ++count;
245          }
246 <        assertEquals(count, 5);
246 >        assertEquals(5, count);
247      }
248  
249      /**
# Line 501 | Line 513 | public class ConcurrentSkipListMapTest e
513       * lowerEntry, higherEntry, ceilingEntry, and floorEntry return
514       * immutable entries
515       */
516 <    public void testEntryImmutablity() {
516 >    public void testEntryImmutability() {
517          ConcurrentSkipListMap map = map5();
518          Map.Entry e = map.lowerEntry(three);
519          assertEquals(two, e.getKey());
# Line 682 | Line 694 | public class ConcurrentSkipListMapTest e
694       * get(null) of nonempty map throws NPE
695       */
696      public void testGet_NullPointerException() {
697 +        ConcurrentSkipListMap c = map5();
698          try {
686            ConcurrentSkipListMap c = map5();
699              c.get(null);
700              shouldThrow();
701          } catch (NullPointerException success) {}
# Line 693 | Line 705 | public class ConcurrentSkipListMapTest e
705       * containsKey(null) of nonempty map throws NPE
706       */
707      public void testContainsKey_NullPointerException() {
708 +        ConcurrentSkipListMap c = map5();
709          try {
697            ConcurrentSkipListMap c = map5();
710              c.containsKey(null);
711              shouldThrow();
712          } catch (NullPointerException success) {}
# Line 704 | Line 716 | public class ConcurrentSkipListMapTest e
716       * containsValue(null) throws NPE
717       */
718      public void testContainsValue_NullPointerException() {
719 +        ConcurrentSkipListMap c = new ConcurrentSkipListMap();
720          try {
708            ConcurrentSkipListMap c = new ConcurrentSkipListMap();
721              c.containsValue(null);
722              shouldThrow();
723          } catch (NullPointerException success) {}
# Line 715 | Line 727 | public class ConcurrentSkipListMapTest e
727       * put(null,x) throws NPE
728       */
729      public void testPut1_NullPointerException() {
730 +        ConcurrentSkipListMap c = map5();
731          try {
719            ConcurrentSkipListMap c = map5();
732              c.put(null, "whatever");
733              shouldThrow();
734          } catch (NullPointerException success) {}
# Line 726 | Line 738 | public class ConcurrentSkipListMapTest e
738       * putIfAbsent(null, x) throws NPE
739       */
740      public void testPutIfAbsent1_NullPointerException() {
741 +        ConcurrentSkipListMap c = map5();
742          try {
730            ConcurrentSkipListMap c = map5();
743              c.putIfAbsent(null, "whatever");
744              shouldThrow();
745          } catch (NullPointerException success) {}
# Line 737 | Line 749 | public class ConcurrentSkipListMapTest e
749       * replace(null, x) throws NPE
750       */
751      public void testReplace_NullPointerException() {
752 +        ConcurrentSkipListMap c = map5();
753          try {
741            ConcurrentSkipListMap c = map5();
754              c.replace(null, "whatever");
755              shouldThrow();
756          } catch (NullPointerException success) {}
# Line 748 | Line 760 | public class ConcurrentSkipListMapTest e
760       * replace(null, x, y) throws NPE
761       */
762      public void testReplaceValue_NullPointerException() {
763 +        ConcurrentSkipListMap c = map5();
764          try {
752            ConcurrentSkipListMap c = map5();
765              c.replace(null, one, "whatever");
766              shouldThrow();
767          } catch (NullPointerException success) {}
# Line 759 | Line 771 | public class ConcurrentSkipListMapTest e
771       * remove(null) throws NPE
772       */
773      public void testRemove1_NullPointerException() {
774 +        ConcurrentSkipListMap c = new ConcurrentSkipListMap();
775 +        c.put("sadsdf", "asdads");
776          try {
763            ConcurrentSkipListMap c = new ConcurrentSkipListMap();
764            c.put("sadsdf", "asdads");
777              c.remove(null);
778              shouldThrow();
779          } catch (NullPointerException success) {}
# Line 771 | Line 783 | public class ConcurrentSkipListMapTest e
783       * remove(null, x) throws NPE
784       */
785      public void testRemove2_NullPointerException() {
786 +        ConcurrentSkipListMap c = new ConcurrentSkipListMap();
787 +        c.put("sadsdf", "asdads");
788          try {
775            ConcurrentSkipListMap c = new ConcurrentSkipListMap();
776            c.put("sadsdf", "asdads");
789              c.remove(null, "whatever");
790              shouldThrow();
791          } catch (NullPointerException success) {}
# Line 795 | Line 807 | public class ConcurrentSkipListMapTest e
807          NavigableMap x = map5();
808          NavigableMap y = serialClone(x);
809  
810 <        assertTrue(x != y);
810 >        assertNotSame(x, y);
811          assertEquals(x.size(), y.size());
812          assertEquals(x.toString(), y.toString());
813          assertEquals(x, y);
# Line 986 | Line 998 | public class ConcurrentSkipListMapTest e
998      static NavigableMap<Integer, Integer> newMap(Class cl) throws Exception {
999          NavigableMap<Integer, Integer> result =
1000              (NavigableMap<Integer, Integer>) cl.newInstance();
1001 <        assertEquals(result.size(), 0);
1001 >        assertEquals(0, result.size());
1002          assertFalse(result.keySet().iterator().hasNext());
1003          return result;
1004      }
# Line 1018 | Line 1030 | public class ConcurrentSkipListMapTest e
1030          // Add entries till we're back to original size
1031          while (map.size() < size) {
1032              int key = min + rnd.nextInt(rangeSize);
1033 <            assertTrue(key >= min && key<= max);
1033 >            assertTrue(key >= min && key <= max);
1034              put(map, key);
1035          }
1036      }
# Line 1043 | Line 1055 | public class ConcurrentSkipListMapTest e
1055          // Add entries till we're back to original size
1056          while (map.size() < size) {
1057              int key = min - 5 + rnd.nextInt(rangeSize + 10);
1058 <            if (key >= min && key<= max) {
1058 >            if (key >= min && key <= max) {
1059                  put(map, key);
1060              } else {
1061                  try {
# Line 1213 | Line 1225 | public class ConcurrentSkipListMapTest e
1225              if (bsContainsI)
1226                  size++;
1227          }
1228 <        assertEquals(map.size(), size);
1228 >        assertEquals(size, map.size());
1229  
1230          // Test contents using contains keySet iterator
1231          int size2 = 0;
# Line 1261 | Line 1273 | public class ConcurrentSkipListMapTest e
1273      }
1274  
1275      static boolean eq(Integer i, int j) {
1276 <        return i == null ? j == -1 : i == j;
1276 >        return (i == null) ? j == -1 : i == j;
1277      }
1278  
1279   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines