[cvs] / jsr166 / src / test / tck / BlockingQueueTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/BlockingQueueTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10, Tue Jun 14 03:22:38 2011 UTC revision 1.11, Tue Jun 14 04:30:06 2011 UTC
# Line 181  Line 181 
181      }      }
182    
183      /**      /**
184       * drainTo(c, -n) returns 0       * drainTo(c, n) returns 0 and does nothing when n <= 0
185       */       */
186      public void testDrainToNegativeMaxElements() {      public void testDrainToNonPositiveMaxElements() {
187          final BlockingQueue q = emptyCollection();          final BlockingQueue q = emptyCollection();
188          assertEquals(0, q.drainTo(new ArrayList(), -42));          final int[] ns = { 0, -1, -42, Integer.MIN_VALUE };
189      }          for (int n : ns)
190                assertEquals(0, q.drainTo(new ArrayList(), n));
191      /**          if (q.remainingCapacity() > 0) {
192       * drainTo(c, 0) returns 0 and does nothing              // Not SynchronousQueue, that is
      */  
     public void testDrainToZeroMaxElements() {  
         final BlockingQueue q = emptyCollection();  
         if (q.remainingCapacity() == 0) {  
             // SynchronousQueue, for example  
             assertEquals(0, q.drainTo(new ArrayList(), 0));  
         } else {  
193              Object one = makeElement(1);              Object one = makeElement(1);
194              q.add(one);              q.add(one);
195              ArrayList c = new ArrayList();              ArrayList c = new ArrayList();
196              assertEquals(0, q.drainTo(c, 0));              for (int n : ns)
197                    assertEquals(0, q.drainTo(new ArrayList(), n));
198              assertEquals(1, q.size());              assertEquals(1, q.size());
199              assertSame(one, q.poll());              assertSame(one, q.poll());
200              assertTrue(c.isEmpty());              assertTrue(c.isEmpty());

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8