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.9 by jsr166, Sat Nov 21 10:29:50 2009 UTC vs.
Revision 1.11 by jsr166, Sun Nov 22 18:57:17 2009 UTC

# Line 19 | Line 19 | public class ConcurrentSkipListSetTest e
19  
20      static class MyReverseComparator implements Comparator {
21          public int compare(Object x, Object y) {
22 <            int i = ((Integer)x).intValue();
23 <            int j = ((Integer)y).intValue();
24 <            if (i < j) return 1;
25 <            if (i > j) return -1;
26 <            return 0;
22 >            return ((Comparable)y).compareTo(x);
23          }
24      }
25  
# Line 245 | Line 241 | public class ConcurrentSkipListSetTest e
241          assertFalse(q.addAll(Arrays.asList(empty)));
242          assertTrue(q.addAll(Arrays.asList(ints)));
243          for (int i = 0; i < SIZE; ++i)
244 <            assertEquals(new Integer(i), q.pollFirst());
244 >            assertEquals(i, q.pollFirst());
245      }
246  
247      /**
# Line 254 | Line 250 | public class ConcurrentSkipListSetTest e
250      public void testPollFirst() {
251          ConcurrentSkipListSet q = populatedSet(SIZE);
252          for (int i = 0; i < SIZE; ++i) {
253 <            assertEquals(i, ((Integer)q.pollFirst()).intValue());
253 >            assertEquals(i, q.pollFirst());
254          }
255          assertNull(q.pollFirst());
256      }
# Line 265 | Line 261 | public class ConcurrentSkipListSetTest e
261      public void testPollLast() {
262          ConcurrentSkipListSet q = populatedSet(SIZE);
263          for (int i = SIZE-1; i >= 0; --i) {
264 <            assertEquals(i, ((Integer)q.pollLast()).intValue());
264 >            assertEquals(i, q.pollLast());
265          }
266          assertNull(q.pollFirst());
267      }
# Line 664 | Line 660 | public class ConcurrentSkipListSetTest e
660      /**
661       * Subsets of subsets subdivide correctly
662       */
663 <    public void testRecursiveSubSets() {
663 >    public void testRecursiveSubSets() throws Exception {
664          int setSize = 1000;
665          Class cl = ConcurrentSkipListSet.class;
666  
# Line 683 | Line 679 | public class ConcurrentSkipListSetTest e
679                     0, setSize - 1, true);
680      }
681  
682 <    static NavigableSet<Integer> newSet(Class cl) {
683 <        NavigableSet<Integer> result = null;
688 <        try {
689 <            result = (NavigableSet<Integer>) cl.newInstance();
690 <        } catch (Exception e) {
691 <            fail();
692 <        }
682 >    static NavigableSet<Integer> newSet(Class cl) throws Exception {
683 >        NavigableSet<Integer> result = (NavigableSet<Integer>) cl.newInstance();
684          assertEquals(result.size(), 0);
685          assertFalse(result.iterator().hasNext());
686          return result;
# Line 752 | Line 743 | public class ConcurrentSkipListSetTest e
743              } else {
744                  try {
745                      set.add(element);
746 <                    fail();
747 <                } catch (IllegalArgumentException e) {
757 <                    // expected
758 <                }
746 >                    shouldThrow();
747 >                } catch (IllegalArgumentException success) {}
748              }
749          }
750      }
# Line 954 | Line 943 | public class ConcurrentSkipListSetTest e
943              assertEq(rs.last(),  -1);
944              try {
945                  set.first();
946 <                fail();
947 <            } catch (NoSuchElementException e) {
959 <                // expected
960 <            }
946 >                shouldThrow();
947 >            } catch (NoSuchElementException success) {}
948              try {
949                  set.last();
950 <                fail();
951 <            } catch (NoSuchElementException e) {
965 <                // expected
966 <            }
950 >                shouldThrow();
951 >            } catch (NoSuchElementException success) {}
952          }
953      }
954  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines