[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.11, Tue Jun 14 04:30:06 2011 UTC revision 1.12, Fri Jul 15 18:49:31 2011 UTC
# Line 327  Line 327 
327          awaitTermination(t);          awaitTermination(t);
328      }      }
329    
330        /**
331         * remove(x) removes x and returns true if present
332         * TODO: move to superclass CollectionTest.java
333         */
334        public void testRemoveElement() {
335            final BlockingQueue q = emptyCollection();
336            final int size = Math.min(q.remainingCapacity(), SIZE);
337            final Object[] elts = new Object[size];
338            assertFalse(q.contains(makeElement(99)));
339            assertFalse(q.remove(makeElement(99)));
340            checkEmpty(q);
341            for (int i = 0; i < size; i++)
342                q.add(elts[i] = makeElement(i));
343            for (int i = 1; i < size; i+=2) {
344                for (int pass = 0; pass < 2; pass++) {
345                    assertEquals((pass == 0), q.contains(elts[i]));
346                    assertEquals((pass == 0), q.remove(elts[i]));
347                    assertFalse(q.contains(elts[i]));
348                    assertTrue(q.contains(elts[i-1]));
349                    if (i < size - 1)
350                        assertTrue(q.contains(elts[i+1]));
351                }
352            }
353            if (size > 0)
354                assertTrue(q.contains(elts[0]));
355            for (int i = size-2; i >= 0; i-=2) {
356                assertTrue(q.contains(elts[i]));
357                assertFalse(q.contains(elts[i+1]));
358                assertTrue(q.remove(elts[i]));
359                assertFalse(q.contains(elts[i]));
360                assertFalse(q.remove(elts[i+1]));
361                assertFalse(q.contains(elts[i+1]));
362            }
363            checkEmpty(q);
364        }
365    
366      /** For debugging. */      /** For debugging. */
367      public void XXXXtestFails() {      public void XXXXtestFails() {
368          fail(emptyCollection().getClass().toString());          fail(emptyCollection().getClass().toString());

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

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8