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.34 by jsr166, Wed Dec 31 21:45:16 2014 UTC vs.
Revision 1.40 by jsr166, Fri Aug 4 03:00:20 2017 UTC

# Line 22 | Line 22 | 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);
# Line 694 | 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 {
698            ConcurrentSkipListMap c = map5();
699              c.get(null);
700              shouldThrow();
701          } catch (NullPointerException success) {}
# Line 705 | 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 {
709            ConcurrentSkipListMap c = map5();
710              c.containsKey(null);
711              shouldThrow();
712          } catch (NullPointerException success) {}
# Line 716 | Line 716 | public class ConcurrentSkipListMapTest e
716       * containsValue(null) throws NPE
717       */
718      public void testContainsValue_NullPointerException() {
719 +        ConcurrentSkipListMap c = new ConcurrentSkipListMap();
720          try {
720            ConcurrentSkipListMap c = new ConcurrentSkipListMap();
721              c.containsValue(null);
722              shouldThrow();
723          } catch (NullPointerException success) {}
# Line 727 | Line 727 | public class ConcurrentSkipListMapTest e
727       * put(null,x) throws NPE
728       */
729      public void testPut1_NullPointerException() {
730 +        ConcurrentSkipListMap c = map5();
731          try {
731            ConcurrentSkipListMap c = map5();
732              c.put(null, "whatever");
733              shouldThrow();
734          } catch (NullPointerException success) {}
# Line 738 | Line 738 | public class ConcurrentSkipListMapTest e
738       * putIfAbsent(null, x) throws NPE
739       */
740      public void testPutIfAbsent1_NullPointerException() {
741 +        ConcurrentSkipListMap c = map5();
742          try {
742            ConcurrentSkipListMap c = map5();
743              c.putIfAbsent(null, "whatever");
744              shouldThrow();
745          } catch (NullPointerException success) {}
# Line 749 | Line 749 | public class ConcurrentSkipListMapTest e
749       * replace(null, x) throws NPE
750       */
751      public void testReplace_NullPointerException() {
752 +        ConcurrentSkipListMap c = map5();
753          try {
753            ConcurrentSkipListMap c = map5();
754              c.replace(null, "whatever");
755              shouldThrow();
756          } catch (NullPointerException success) {}
# Line 760 | 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 {
764            ConcurrentSkipListMap c = map5();
765              c.replace(null, one, "whatever");
766              shouldThrow();
767          } catch (NullPointerException success) {}
# Line 771 | 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 {
775            ConcurrentSkipListMap c = new ConcurrentSkipListMap();
776            c.put("sadsdf", "asdads");
777              c.remove(null);
778              shouldThrow();
779          } catch (NullPointerException success) {}
# Line 783 | 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 {
787            ConcurrentSkipListMap c = new ConcurrentSkipListMap();
788            c.put("sadsdf", "asdads");
789              c.remove(null, "whatever");
790              shouldThrow();
791          } catch (NullPointerException success) {}
# Line 801 | Line 801 | public class ConcurrentSkipListMapTest e
801      }
802  
803      /**
804 <     * A deserialized map equals original
804 >     * A cloned map equals original
805 >     */
806 >    public void testClone() {
807 >        ConcurrentSkipListMap x = map5();
808 >        ConcurrentSkipListMap y = x.clone();
809 >
810 >        assertNotSame(x, y);
811 >        assertEquals(x.size(), y.size());
812 >        assertEquals(x.toString(), y.toString());
813 >        assertEquals(x, y);
814 >        assertEquals(y, x);
815 >        y.clear();
816 >        assertTrue(y.isEmpty());
817 >        assertFalse(x.equals(y));
818 >    }
819 >
820 >    /**
821 >     * A deserialized/reserialized map equals original
822       */
823      public void testSerialization() throws Exception {
824          NavigableMap x = map5();
# Line 812 | Line 829 | public class ConcurrentSkipListMapTest e
829          assertEquals(x.toString(), y.toString());
830          assertEquals(x, y);
831          assertEquals(y, x);
832 +        y.clear();
833 +        assertTrue(y.isEmpty());
834 +        assertFalse(x.equals(y));
835      }
836  
837      /**
# Line 997 | Line 1017 | public class ConcurrentSkipListMapTest e
1017  
1018      static NavigableMap<Integer, Integer> newMap(Class cl) throws Exception {
1019          NavigableMap<Integer, Integer> result =
1020 <            (NavigableMap<Integer, Integer>) cl.newInstance();
1020 >            (NavigableMap<Integer, Integer>) cl.getConstructor().newInstance();
1021          assertEquals(0, result.size());
1022          assertFalse(result.keySet().iterator().hasNext());
1023          return result;
# Line 1273 | Line 1293 | public class ConcurrentSkipListMapTest e
1293      }
1294  
1295      static boolean eq(Integer i, int j) {
1296 <        return i == null ? j == -1 : i == j;
1296 >        return (i == null) ? j == -1 : i == j;
1297      }
1298  
1299   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines