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

Comparing jsr166/src/test/tck/ConcurrentSkipListSubSetTest.java (file contents):
Revision 1.4 by dl, Thu Apr 20 20:35:00 2006 UTC vs.
Revision 1.6 by jsr166, Mon Nov 16 04:57:10 2009 UTC

# Line 11 | Line 11 | import java.io.*;
11  
12   public class ConcurrentSkipListSubSetTest extends JSR166TestCase {
13      public static void main(String[] args) {
14 <        junit.textui.TestRunner.run (suite());  
14 >        junit.textui.TestRunner.run (suite());
15      }
16      public static Test suite() {
17          return new TestSuite(ConcurrentSkipListSubSetTest.class);
18      }
19  
20 <    static class MyReverseComparator implements Comparator {
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();
# Line 35 | Line 35 | public class ConcurrentSkipListSubSetTes
35          ConcurrentSkipListSet q = new ConcurrentSkipListSet();
36          assertTrue(q.isEmpty());
37  
38 <        for(int i = n-1; i >= 0; i-=2)
38 >        for (int i = n-1; i >= 0; i-=2)
39              assertTrue(q.add(new Integer(i)));
40 <        for(int i = (n & 1); i < n; i+=2)
40 >        for (int i = (n & 1); i < n; i+=2)
41              assertTrue(q.add(new Integer(i)));
42          assertTrue(q.add(new Integer(-n)));
43          assertTrue(q.add(new Integer(n)));
# Line 81 | Line 81 | public class ConcurrentSkipListSubSetTes
81          return s;
82      }
83  
84 <    private static NavigableSet set0() {  
84 >    private static NavigableSet set0() {
85          ConcurrentSkipListSet set = new ConcurrentSkipListSet();
86          assertTrue(set.isEmpty());
87          return set.tailSet(m1, true);
88      }
89  
90 <    private static NavigableSet dset0() {  
90 >    private static NavigableSet dset0() {
91          ConcurrentSkipListSet set = new ConcurrentSkipListSet();
92          assertTrue(set.isEmpty());
93          return set;
94      }
95 <
95 >
96      /**
97       * A new set has unbounded capacity
98       */
# Line 138 | Line 138 | public class ConcurrentSkipListSubSetTes
138              NavigableSet q = set0();
139              q.add(null);
140              shouldThrow();
141 <        } catch (NullPointerException success) { }  
141 >        } catch (NullPointerException success) { }
142      }
143  
144      /**
# Line 169 | Line 169 | public class ConcurrentSkipListSubSetTes
169              q.add(new Object());
170              shouldThrow();
171          }
172 <        catch(ClassCastException success) {}
172 >        catch (ClassCastException success) {}
173      }
174  
175  
# Line 255 | Line 255 | public class ConcurrentSkipListSubSetTes
255          }
256          assertTrue(q.isEmpty());
257      }
258 <        
258 >
259      /**
260       * contains(x) reports true when elements added but not yet removed
261       */
# Line 331 | Line 331 | public class ConcurrentSkipListSubSetTes
331          }
332      }
333  
334 <    
334 >
335  
336      /**
337       * lower returns preceding element
# Line 416 | Line 416 | public class ConcurrentSkipListSubSetTes
416          NavigableSet q = populatedSet(SIZE);
417          Object[] o = q.toArray();
418          Arrays.sort(o);
419 <        for(int i = 0; i < o.length; i++)
419 >        for (int i = 0; i < o.length; i++)
420              assertEquals(o[i], q.pollFirst());
421      }
422  
# Line 428 | Line 428 | public class ConcurrentSkipListSubSetTes
428          Integer[] ints = new Integer[SIZE];
429          ints = (Integer[])q.toArray(ints);
430          Arrays.sort(ints);
431 <        for(int i = 0; i < ints.length; i++)
431 >        for (int i = 0; i < ints.length; i++)
432              assertEquals(ints[i], q.pollFirst());
433      }
434 <    
434 >
435      /**
436       * iterator iterates through all elements
437       */
# Line 439 | Line 439 | public class ConcurrentSkipListSubSetTes
439          NavigableSet q = populatedSet(SIZE);
440          int i = 0;
441          Iterator it = q.iterator();
442 <        while(it.hasNext()) {
442 >        while (it.hasNext()) {
443              assertTrue(q.contains(it.next()));
444              ++i;
445          }
# Line 453 | Line 453 | public class ConcurrentSkipListSubSetTes
453          NavigableSet q = set0();
454          int i = 0;
455          Iterator it = q.iterator();
456 <        while(it.hasNext()) {
456 >        while (it.hasNext()) {
457              assertTrue(q.contains(it.next()));
458              ++i;
459          }
# Line 489 | Line 489 | public class ConcurrentSkipListSubSetTes
489          for (int i = 0; i < SIZE; ++i) {
490              assertTrue(s.indexOf(String.valueOf(i)) >= 0);
491          }
492 <    }        
492 >    }
493  
494      /**
495 <     * A deserialized serialized set has same elements
495 >     * A deserialized serialized set has same elements
496       */
497      public void testSerialization() {
498          NavigableSet q = populatedSet(SIZE);
# Line 506 | Line 506 | public class ConcurrentSkipListSubSetTes
506              ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
507              NavigableSet r = (NavigableSet)in.readObject();
508              assertEquals(q.size(), r.size());
509 <            while (!q.isEmpty())
509 >            while (!q.isEmpty())
510                  assertEquals(q.pollFirst(), r.pollFirst());
511 <        } catch(Exception e){
511 >        } catch (Exception e){
512              e.printStackTrace();
513              unexpectedException();
514          }
# Line 656 | Line 656 | public class ConcurrentSkipListSubSetTes
656              NavigableSet q = dset0();
657              q.add(null);
658              shouldThrow();
659 <        } catch (NullPointerException success) { }  
659 >        } catch (NullPointerException success) { }
660      }
661  
662      /**
# Line 687 | Line 687 | public class ConcurrentSkipListSubSetTes
687              q.add(new Object());
688              shouldThrow();
689          }
690 <        catch(ClassCastException success) {}
690 >        catch (ClassCastException success) {}
691      }
692  
693  
# Line 773 | Line 773 | public class ConcurrentSkipListSubSetTes
773          }
774          assertTrue(q.isEmpty());
775      }
776 <        
776 >
777      /**
778       * contains(x) reports true when elements added but not yet removed
779       */
# Line 849 | Line 849 | public class ConcurrentSkipListSubSetTes
849          }
850      }
851  
852 <    
852 >
853  
854      /**
855       * lower returns preceding element
# Line 934 | Line 934 | public class ConcurrentSkipListSubSetTes
934          NavigableSet q = populatedSet(SIZE);
935          Object[] o = q.toArray();
936          Arrays.sort(o);
937 <        for(int i = 0; i < o.length; i++)
937 >        for (int i = 0; i < o.length; i++)
938              assertEquals(o[i], q.pollFirst());
939      }
940  
# Line 946 | Line 946 | public class ConcurrentSkipListSubSetTes
946          Integer[] ints = new Integer[SIZE];
947          ints = (Integer[])q.toArray(ints);
948          Arrays.sort(ints);
949 <        for(int i = 0; i < ints.length; i++)
949 >        for (int i = 0; i < ints.length; i++)
950              assertEquals(ints[i], q.pollFirst());
951      }
952 <    
952 >
953      /**
954       * iterator iterates through all elements
955       */
# Line 957 | Line 957 | public class ConcurrentSkipListSubSetTes
957          NavigableSet q = populatedSet(SIZE);
958          int i = 0;
959          Iterator it = q.iterator();
960 <        while(it.hasNext()) {
960 >        while (it.hasNext()) {
961              assertTrue(q.contains(it.next()));
962              ++i;
963          }
# Line 971 | Line 971 | public class ConcurrentSkipListSubSetTes
971          NavigableSet q = dset0();
972          int i = 0;
973          Iterator it = q.iterator();
974 <        while(it.hasNext()) {
974 >        while (it.hasNext()) {
975              assertTrue(q.contains(it.next()));
976              ++i;
977          }
# Line 1007 | Line 1007 | public class ConcurrentSkipListSubSetTes
1007          for (int i = 0; i < SIZE; ++i) {
1008              assertTrue(s.indexOf(String.valueOf(i)) >= 0);
1009          }
1010 <    }        
1010 >    }
1011  
1012      /**
1013 <     * A deserialized serialized set has same elements
1013 >     * A deserialized serialized set has same elements
1014       */
1015      public void testDescendingSerialization() {
1016          NavigableSet q = populatedSet(SIZE);
# Line 1024 | Line 1024 | public class ConcurrentSkipListSubSetTes
1024              ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
1025              NavigableSet r = (NavigableSet)in.readObject();
1026              assertEquals(q.size(), r.size());
1027 <            while (!q.isEmpty())
1027 >            while (!q.isEmpty())
1028                  assertEquals(q.pollFirst(), r.pollFirst());
1029 <        } catch(Exception e){
1029 >        } catch (Exception e){
1030              e.printStackTrace();
1031              unexpectedException();
1032          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines