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

Comparing jsr166/src/test/tck/ConcurrentLinkedQueueTest.java (file contents):
Revision 1.37 by jsr166, Sat Apr 25 04:55:30 2015 UTC vs.
Revision 1.40 by jsr166, Sun May 24 01:42:14 2015 UTC

# Line 62 | Line 62 | public class ConcurrentLinkedQueueTest e
62       */
63      public void testConstructor4() {
64          try {
65 <            Integer[] ints = new Integer[SIZE];
66 <            new ConcurrentLinkedQueue(Arrays.asList(ints));
65 >            new ConcurrentLinkedQueue(Arrays.asList(new Integer[SIZE]));
66              shouldThrow();
67          } catch (NullPointerException success) {}
68      }
# Line 72 | Line 71 | public class ConcurrentLinkedQueueTest e
71       * Initializing from Collection with some null elements throws NPE
72       */
73      public void testConstructor5() {
74 +        Integer[] ints = new Integer[SIZE];
75 +        for (int i = 0; i < SIZE - 1; ++i)
76 +            ints[i] = new Integer(i);
77          try {
76            Integer[] ints = new Integer[SIZE];
77            for (int i = 0; i < SIZE-1; ++i)
78                ints[i] = new Integer(i);
78              new ConcurrentLinkedQueue(Arrays.asList(ints));
79              shouldThrow();
80          } catch (NullPointerException success) {}
# Line 113 | Line 112 | public class ConcurrentLinkedQueueTest e
112      public void testSize() {
113          ConcurrentLinkedQueue q = populatedQueue(SIZE);
114          for (int i = 0; i < SIZE; ++i) {
115 <            assertEquals(SIZE-i, q.size());
115 >            assertEquals(SIZE - i, q.size());
116              q.remove();
117          }
118          for (int i = 0; i < SIZE; ++i) {
# Line 126 | Line 125 | public class ConcurrentLinkedQueueTest e
125       * offer(null) throws NPE
126       */
127      public void testOfferNull() {
128 +        ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
129          try {
130            ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
130              q.offer(null);
131              shouldThrow();
132          } catch (NullPointerException success) {}
# Line 137 | Line 136 | public class ConcurrentLinkedQueueTest e
136       * add(null) throws NPE
137       */
138      public void testAddNull() {
139 +        ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
140          try {
141            ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
141              q.add(null);
142              shouldThrow();
143          } catch (NullPointerException success) {}
# Line 168 | Line 167 | public class ConcurrentLinkedQueueTest e
167       * addAll(null) throws NPE
168       */
169      public void testAddAll1() {
170 +        ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
171          try {
172            ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
172              q.addAll(null);
173              shouldThrow();
174          } catch (NullPointerException success) {}
# Line 179 | Line 178 | public class ConcurrentLinkedQueueTest e
178       * addAll(this) throws IAE
179       */
180      public void testAddAllSelf() {
181 +        ConcurrentLinkedQueue q = populatedQueue(SIZE);
182          try {
183            ConcurrentLinkedQueue q = populatedQueue(SIZE);
183              q.addAll(q);
184              shouldThrow();
185          } catch (IllegalArgumentException success) {}
# Line 190 | Line 189 | public class ConcurrentLinkedQueueTest e
189       * addAll of a collection with null elements throws NPE
190       */
191      public void testAddAll2() {
192 +        ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
193          try {
194 <            ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
195 <            Integer[] ints = new Integer[SIZE];
196 <            q.addAll(Arrays.asList(ints));
194 >            q.addAll(Arrays.asList(new Integer[SIZE]));
195              shouldThrow();
196          } catch (NullPointerException success) {}
197      }
# Line 203 | Line 201 | public class ConcurrentLinkedQueueTest e
201       * possibly adding some elements
202       */
203      public void testAddAll3() {
204 +        ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
205 +        Integer[] ints = new Integer[SIZE];
206 +        for (int i = 0; i < SIZE - 1; ++i)
207 +            ints[i] = new Integer(i);
208          try {
207            ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
208            Integer[] ints = new Integer[SIZE];
209            for (int i = 0; i < SIZE-1; ++i)
210                ints[i] = new Integer(i);
209              q.addAll(Arrays.asList(ints));
210              shouldThrow();
211          } catch (NullPointerException success) {}
# Line 291 | Line 289 | public class ConcurrentLinkedQueueTest e
289              assertTrue(q.contains(i));
290              assertTrue(q.remove(i));
291              assertFalse(q.contains(i));
292 <            assertTrue(q.contains(i-1));
292 >            assertTrue(q.contains(i - 1));
293          }
294          for (int i = 0; i < SIZE; i += 2) {
295              assertTrue(q.contains(i));
296              assertTrue(q.remove(i));
297              assertFalse(q.contains(i));
298 <            assertFalse(q.remove(i+1));
299 <            assertFalse(q.contains(i+1));
298 >            assertFalse(q.remove(i + 1));
299 >            assertFalse(q.contains(i + 1));
300          }
301          assertTrue(q.isEmpty());
302      }
# Line 357 | Line 355 | public class ConcurrentLinkedQueueTest e
355                  assertTrue(changed);
356  
357              assertTrue(q.containsAll(p));
358 <            assertEquals(SIZE-i, q.size());
358 >            assertEquals(SIZE - i, q.size());
359              p.remove();
360          }
361      }
# Line 370 | Line 368 | public class ConcurrentLinkedQueueTest e
368              ConcurrentLinkedQueue q = populatedQueue(SIZE);
369              ConcurrentLinkedQueue p = populatedQueue(i);
370              assertTrue(q.removeAll(p));
371 <            assertEquals(SIZE-i, q.size());
371 >            assertEquals(SIZE - i, q.size());
372              for (int j = 0; j < i; ++j) {
373                  Integer x = (Integer)(p.remove());
374                  assertFalse(q.contains(x));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines