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

Comparing jsr166/src/test/tck/ConcurrentSkipListSetTest.java (file contents):
Revision 1.37 by jsr166, Sat Feb 28 20:13:46 2015 UTC vs.
Revision 1.43 by jsr166, Thu Jun 2 01:15:46 2016 UTC

# Line 21 | Line 21 | import junit.framework.TestSuite;
21  
22   public class ConcurrentSkipListSetTest extends JSR166TestCase {
23      public static void main(String[] args) {
24 <        junit.textui.TestRunner.run(suite());
24 >        main(suite(), args);
25      }
26      public static Test suite() {
27          return new TestSuite(ConcurrentSkipListSetTest.class);
# Line 41 | Line 41 | public class ConcurrentSkipListSetTest e
41          ConcurrentSkipListSet<Integer> q =
42              new ConcurrentSkipListSet<Integer>();
43          assertTrue(q.isEmpty());
44 <        for (int i = n-1; i >= 0; i -= 2)
44 >        for (int i = n - 1; i >= 0; i -= 2)
45              assertTrue(q.add(new Integer(i)));
46          for (int i = (n & 1); i < n; i += 2)
47              assertTrue(q.add(new Integer(i)));
# Line 87 | Line 87 | public class ConcurrentSkipListSetTest e
87       */
88      public void testConstructor4() {
89          try {
90 <            Integer[] ints = new Integer[SIZE];
91 <            new ConcurrentSkipListSet(Arrays.asList(ints));
90 >            new ConcurrentSkipListSet(Arrays.asList(new Integer[SIZE]));
91              shouldThrow();
92          } catch (NullPointerException success) {}
93      }
# Line 97 | Line 96 | public class ConcurrentSkipListSetTest e
96       * Initializing from Collection with some null elements throws NPE
97       */
98      public void testConstructor5() {
99 +        Integer[] ints = new Integer[SIZE];
100 +        for (int i = 0; i < SIZE - 1; ++i)
101 +            ints[i] = new Integer(i);
102          try {
101            Integer[] ints = new Integer[SIZE];
102            for (int i = 0; i < SIZE-1; ++i)
103                ints[i] = new Integer(i);
103              new ConcurrentSkipListSet(Arrays.asList(ints));
104              shouldThrow();
105          } catch (NullPointerException success) {}
# Line 129 | Line 128 | public class ConcurrentSkipListSetTest e
128          for (int i = 0; i < SIZE; ++i)
129              ints[i] = new Integer(i);
130          q.addAll(Arrays.asList(ints));
131 <        for (int i = SIZE-1; i >= 0; --i)
131 >        for (int i = SIZE - 1; i >= 0; --i)
132              assertEquals(ints[i], q.pollFirst());
133      }
134  
# Line 153 | Line 152 | public class ConcurrentSkipListSetTest e
152      public void testSize() {
153          ConcurrentSkipListSet q = populatedSet(SIZE);
154          for (int i = 0; i < SIZE; ++i) {
155 <            assertEquals(SIZE-i, q.size());
155 >            assertEquals(SIZE - i, q.size());
156              q.pollFirst();
157          }
158          for (int i = 0; i < SIZE; ++i) {
# Line 200 | Line 199 | public class ConcurrentSkipListSetTest e
199              q.add(new Object());
200              q.add(new Object());
201              shouldThrow();
202 <        } catch (ClassCastException success) {}
202 >        } catch (ClassCastException success) {
203 >            assertTrue(q.size() < 2);
204 >            for (int i = 0, size = q.size(); i < size; i++)
205 >                assertTrue(q.pollFirst().getClass() == Object.class);
206 >            assertNull(q.pollFirst());
207 >            assertTrue(q.isEmpty());
208 >            assertEquals(0, q.size());
209 >        }
210      }
211  
212      /**
# Line 233 | Line 239 | public class ConcurrentSkipListSetTest e
239      public void testAddAll3() {
240          ConcurrentSkipListSet q = new ConcurrentSkipListSet();
241          Integer[] ints = new Integer[SIZE];
242 <        for (int i = 0; i < SIZE-1; ++i)
242 >        for (int i = 0; i < SIZE - 1; ++i)
243              ints[i] = new Integer(i);
244          try {
245              q.addAll(Arrays.asList(ints));
# Line 248 | Line 254 | public class ConcurrentSkipListSetTest e
254          Integer[] empty = new Integer[0];
255          Integer[] ints = new Integer[SIZE];
256          for (int i = 0; i < SIZE; ++i)
257 <            ints[i] = new Integer(SIZE-1-i);
257 >            ints[i] = new Integer(SIZE - 1 - i);
258          ConcurrentSkipListSet q = new ConcurrentSkipListSet();
259          assertFalse(q.addAll(Arrays.asList(empty)));
260          assertTrue(q.addAll(Arrays.asList(ints)));
# Line 272 | Line 278 | public class ConcurrentSkipListSetTest e
278       */
279      public void testPollLast() {
280          ConcurrentSkipListSet q = populatedSet(SIZE);
281 <        for (int i = SIZE-1; i >= 0; --i) {
281 >        for (int i = SIZE - 1; i >= 0; --i) {
282              assertEquals(i, q.pollLast());
283          }
284          assertNull(q.pollFirst());
# Line 287 | Line 293 | public class ConcurrentSkipListSetTest e
293              assertTrue(q.contains(i));
294              assertTrue(q.remove(i));
295              assertFalse(q.contains(i));
296 <            assertTrue(q.contains(i-1));
296 >            assertTrue(q.contains(i - 1));
297          }
298          for (int i = 0; i < SIZE; i += 2) {
299              assertTrue(q.contains(i));
300              assertTrue(q.remove(i));
301              assertFalse(q.contains(i));
302 <            assertFalse(q.remove(i+1));
303 <            assertFalse(q.contains(i+1));
302 >            assertFalse(q.remove(i + 1));
303 >            assertFalse(q.contains(i + 1));
304          }
305          assertTrue(q.isEmpty());
306      }
# Line 353 | Line 359 | public class ConcurrentSkipListSetTest e
359                  assertTrue(changed);
360  
361              assertTrue(q.containsAll(p));
362 <            assertEquals(SIZE-i, q.size());
362 >            assertEquals(SIZE - i, q.size());
363              p.pollFirst();
364          }
365      }
# Line 366 | Line 372 | public class ConcurrentSkipListSetTest e
372              ConcurrentSkipListSet q = populatedSet(SIZE);
373              ConcurrentSkipListSet p = populatedSet(i);
374              assertTrue(q.removeAll(p));
375 <            assertEquals(SIZE-i, q.size());
375 >            assertEquals(SIZE - i, q.size());
376              for (int j = 0; j < i; ++j) {
377                  Integer x = (Integer)(p.pollFirst());
378                  assertFalse(q.contains(x));
# Line 975 | Line 981 | public class ConcurrentSkipListSetTest e
981      }
982  
983      static boolean eq(Integer i, int j) {
984 <        return i == null ? j == -1 : i == j;
984 >        return (i == null) ? j == -1 : i == j;
985      }
986  
987   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines