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

Comparing jsr166/src/test/tck/ConcurrentLinkedDequeTest.java (file contents):
Revision 1.9 by jsr166, Tue May 31 16:16:23 2011 UTC vs.
Revision 1.14 by jsr166, Wed Dec 31 19:05:42 2014 UTC

# Line 6 | Line 6
6   * Pat Fisher, Mike Judd.
7   */
8  
9 import junit.framework.*;
9   import java.util.Arrays;
10   import java.util.Collection;
11 + import java.util.Deque;
12   import java.util.Iterator;
13   import java.util.NoSuchElementException;
14   import java.util.Queue;
15   import java.util.Random;
16   import java.util.concurrent.ConcurrentLinkedDeque;
17  
18 + import junit.framework.Test;
19 + import junit.framework.TestSuite;
20 +
21   public class ConcurrentLinkedDequeTest extends JSR166TestCase {
22  
23      public static void main(String[] args) {
# Line 26 | Line 29 | public class ConcurrentLinkedDequeTest e
29      }
30  
31      /**
32 <     * Create a deque of given size containing consecutive
32 >     * Returns a new deque of given size containing consecutive
33       * Integers 0 ... n.
34       */
35      private ConcurrentLinkedDeque<Integer> populatedDeque(int n) {
# Line 850 | Line 853 | public class ConcurrentLinkedDequeTest e
853          Queue x = populatedDeque(SIZE);
854          Queue y = serialClone(x);
855  
856 <        assertTrue(x != y);
856 >        assertNotSame(x, y);
857          assertEquals(x.size(), y.size());
858          assertEquals(x.toString(), y.toString());
859          assertTrue(Arrays.equals(x.toArray(), y.toArray()));
# Line 861 | Line 864 | public class ConcurrentLinkedDequeTest e
864          assertTrue(y.isEmpty());
865      }
866  
867 +    /**
868 +     * contains(null) always return false.
869 +     * remove(null) always throws NullPointerException.
870 +     */
871 +    public void testNeverContainsNull() {
872 +        Deque<?>[] qs = {
873 +            new ConcurrentLinkedDeque<Object>(),
874 +            populatedDeque(2),
875 +        };
876 +
877 +        for (Deque<?> q : qs) {
878 +            assertFalse(q.contains(null));
879 +            try {
880 +                assertFalse(q.remove(null));
881 +                shouldThrow();
882 +            } catch (NullPointerException success) {}
883 +            try {
884 +                assertFalse(q.removeFirstOccurrence(null));
885 +                shouldThrow();
886 +            } catch (NullPointerException success) {}
887 +            try {
888 +                assertFalse(q.removeLastOccurrence(null));
889 +                shouldThrow();
890 +            } catch (NullPointerException success) {}
891 +        }
892 +    }
893   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines