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

Comparing jsr166/src/test/tck/LinkedBlockingQueueTest.java (file contents):
Revision 1.6 by dl, Sun Oct 5 23:00:40 2003 UTC vs.
Revision 1.10 by dl, Sun Oct 31 14:55:14 2004 UTC

# Line 1 | Line 1
1   /*
2 < * Written by members of JCP JSR-166 Expert Group and released to the
3 < * public domain. Use, modify, and redistribute this code in any way
4 < * without acknowledgement. Other contributors include Andrew Wright,
5 < * Jeffrey Hayes, Pat Fischer, Mike Judd.
2 > * Written by Doug Lea with assistance from members of JCP JSR-166
3 > * Expert Group and released to the public domain, as explained at
4 > * http://creativecommons.org/licenses/publicdomain
5 > * Other contributors include Andrew Wright, Jeffrey Hayes,
6 > * Pat Fisher, Mike Judd.
7   */
8  
9   import junit.framework.*;
# Line 637 | Line 638 | public class LinkedBlockingQueueTest ext
638          assertEquals(SIZE, q.remainingCapacity());
639          q.add(one);
640          assertFalse(q.isEmpty());
641 +        assertTrue(q.contains(one));
642          q.clear();
643          assertTrue(q.isEmpty());
644      }
# Line 731 | Line 733 | public class LinkedBlockingQueueTest ext
733      }
734  
735      /**
736 <     * toArray with incompatable array type throws CCE
736 >     * toArray with incompatible array type throws CCE
737       */
738      public void testToArray1_BadArg() {
739          try {
# Line 955 | Line 957 | public class LinkedBlockingQueueTest ext
957          assertEquals(l.size(), SIZE);
958          for (int i = 0; i < SIZE; ++i)
959              assertEquals(l.get(i), new Integer(i));
960 +        q.add(zero);
961 +        q.add(one);
962 +        assertFalse(q.isEmpty());
963 +        assertTrue(q.contains(zero));
964 +        assertTrue(q.contains(one));
965 +        l.clear();
966 +        q.drainTo(l);
967 +        assertEquals(q.size(), 0);
968 +        assertEquals(l.size(), 2);
969 +        for (int i = 0; i < 2; ++i)
970 +            assertEquals(l.get(i), new Integer(i));
971      }
972  
973      /**
# Line 979 | Line 992 | public class LinkedBlockingQueueTest ext
992              for (int i = 0; i < SIZE; ++i)
993                  assertEquals(l.get(i), new Integer(i));
994              t.join();
995 <            assertTrue(q.size() + l.size() == SIZE+1);
995 >            assertTrue(q.size() + l.size() >= SIZE);
996          } catch(Exception e){
997              unexpectedException();
998          }
# Line 1013 | Line 1026 | public class LinkedBlockingQueueTest ext
1026       * drainTo(c, n) empties first max {n, size} elements of queue into c
1027       */
1028      public void testDrainToN() {
1029 +        LinkedBlockingQueue q = new LinkedBlockingQueue();
1030          for (int i = 0; i < SIZE + 2; ++i) {
1031 <            LinkedBlockingQueue q = populatedQueue(SIZE);
1031 >            for(int j = 0; j < SIZE; j++)
1032 >                assertTrue(q.offer(new Integer(j)));
1033              ArrayList l = new ArrayList();
1034              q.drainTo(l, i);
1035              int k = (i < SIZE)? i : SIZE;
1021            assertEquals(q.size(), SIZE-k);
1036              assertEquals(l.size(), k);
1037 +            assertEquals(q.size(), SIZE-k);
1038              for (int j = 0; j < k; ++j)
1039                  assertEquals(l.get(j), new Integer(j));
1040 +            while (q.poll() != null) ;
1041          }
1042      }
1043  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines