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.3 by dl, Wed Apr 19 15:10:54 2006 UTC vs.
Revision 1.41 by jsr166, Wed Jan 27 01:57:24 2021 UTC

# Line 1 | Line 1
1   /*
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
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import junit.framework.*;
8 < import java.util.*;
9 < import java.util.concurrent.*;
10 < import java.io.*;
7 > import java.util.Arrays;
8 > import java.util.Comparator;
9 > import java.util.Iterator;
10 > import java.util.NavigableSet;
11 > import java.util.SortedSet;
12 > import java.util.concurrent.ConcurrentSkipListSet;
13 >
14 > import junit.framework.Test;
15 > import junit.framework.TestSuite;
16  
17   public class ConcurrentSkipListSubSetTest extends JSR166TestCase {
18      public static void main(String[] args) {
19 <        junit.textui.TestRunner.run (suite());  
19 >        main(suite(), args);
20      }
21      public static Test suite() {
22 <        return new TestSuite(ConcurrentSkipListSubSetTest.class);
22 >        return new TestSuite(ConcurrentSkipListSubSetTest.class);
23      }
24  
25 <    static class MyReverseComparator implements Comparator {
25 >    static class MyReverseComparator implements Comparator {
26 >        @SuppressWarnings("unchecked")
27          public int compare(Object x, Object y) {
28 <            int i = ((Integer)x).intValue();
23 <            int j = ((Integer)y).intValue();
24 <            if (i < j) return 1;
25 <            if (i > j) return -1;
26 <            return 0;
28 >            return ((Comparable)y).compareTo(x);
29          }
30      }
31  
32      /**
33 <     * Create a set of given size containing consecutive
34 <     * Integers 0 ... n.
33 >     * Returns a new set of given size containing consecutive
34 >     * Items 0 ... n - 1.
35       */
36 <    private NavigableSet populatedSet(int n) {
37 <        ConcurrentSkipListSet q = new ConcurrentSkipListSet();
36 >    private static NavigableSet<Item> populatedSet(int n) {
37 >        ConcurrentSkipListSet<Item> q = new ConcurrentSkipListSet<>();
38          assertTrue(q.isEmpty());
39  
40 <        for(int i = n-1; i >= 0; i-=2)
41 <            assertTrue(q.add(new Integer(i)));
42 <        for(int i = (n & 1); i < n; i+=2)
43 <            assertTrue(q.add(new Integer(i)));
44 <        assertTrue(q.add(new Integer(-n)));
45 <        assertTrue(q.add(new Integer(n)));
46 <        NavigableSet s = q.navigableSubSet(new Integer(0), true, new Integer(n), false);
40 >        for (int i = n - 1; i >= 0; i -= 2)
41 >            mustAdd(q, i);
42 >        for (int i = (n & 1); i < n; i += 2)
43 >            mustAdd(q, i);
44 >        mustAdd(q, -n);
45 >        mustAdd(q, n);
46 >        NavigableSet<Item> s = q.subSet(itemFor(0), true, itemFor(n), false);
47          assertFalse(s.isEmpty());
48 <        assertEquals(n, s.size());
48 >        mustEqual(n, s.size());
49          return s;
50      }
51  
52      /**
53 <     * Create set of first 5 ints
53 >     * Returns a new set of first 5 ints.
54       */
55 <    private NavigableSet set5() {
56 <        ConcurrentSkipListSet q = new ConcurrentSkipListSet();
55 >    private static NavigableSet<Item> set5() {
56 >        ConcurrentSkipListSet<Item> q = new ConcurrentSkipListSet<>();
57          assertTrue(q.isEmpty());
58          q.add(one);
59          q.add(two);
# Line 60 | Line 62 | public class ConcurrentSkipListSubSetTes
62          q.add(five);
63          q.add(zero);
64          q.add(seven);
65 <        NavigableSet s = q.navigableSubSet(one, true, seven, false);
66 <        assertEquals(5, s.size());
65 >        NavigableSet<Item> s = q.subSet(one, true, seven, false);
66 >        mustEqual(5, s.size());
67 >        return s;
68 >    }
69 >
70 >    /**
71 >     * Returns a new set of first 5 negative ints.
72 >     */
73 >    private static NavigableSet<Item> dset5() {
74 >        ConcurrentSkipListSet<Item> q = new ConcurrentSkipListSet<>();
75 >        assertTrue(q.isEmpty());
76 >        q.add(minusOne);
77 >        q.add(minusTwo);
78 >        q.add(minusThree);
79 >        q.add(minusFour);
80 >        q.add(minusFive);
81 >        NavigableSet<Item> s = q.descendingSet();
82 >        mustEqual(5, s.size());
83          return s;
84      }
85  
86 <    private static NavigableSet set0() {  
87 <        ConcurrentSkipListSet set = new ConcurrentSkipListSet();
86 >    private static NavigableSet<Item> set0() {
87 >        ConcurrentSkipListSet<Item> set = new ConcurrentSkipListSet<>();
88 >        assertTrue(set.isEmpty());
89 >        return set.tailSet(minusOne, true);
90 >    }
91 >
92 >    private static NavigableSet<Item> dset0() {
93 >        ConcurrentSkipListSet<Item> set = new ConcurrentSkipListSet<>();
94          assertTrue(set.isEmpty());
95 <        return set.navigableTailSet(m1, true);
95 >        return set;
96      }
97 <
97 >
98      /**
99       * A new set has unbounded capacity
100       */
101      public void testConstructor1() {
102 <        assertEquals(0, set0().size());
102 >        mustEqual(0, set0().size());
103      }
104  
81
105      /**
106       * isEmpty is true before add, false after
107       */
108      public void testEmpty() {
109 <        NavigableSet q = set0();
109 >        NavigableSet<Item> q = set0();
110          assertTrue(q.isEmpty());
111 <        q.add(new Integer(1));
111 >        mustAdd(q, one);
112          assertFalse(q.isEmpty());
113 <        q.add(new Integer(2));
113 >        mustAdd(q, two);
114          q.pollFirst();
115          q.pollFirst();
116          assertTrue(q.isEmpty());
# Line 97 | Line 120 | public class ConcurrentSkipListSubSetTes
120       * size changes when elements added and removed
121       */
122      public void testSize() {
123 <        NavigableSet q = populatedSet(SIZE);
123 >        NavigableSet<Item> q = populatedSet(SIZE);
124          for (int i = 0; i < SIZE; ++i) {
125 <            assertEquals(SIZE-i, q.size());
125 >            mustEqual(SIZE - i, q.size());
126              q.pollFirst();
127          }
128          for (int i = 0; i < SIZE; ++i) {
129 <            assertEquals(i, q.size());
130 <            q.add(new Integer(i));
129 >            mustEqual(i, q.size());
130 >            mustAdd(q, i);
131          }
132      }
133  
# Line 112 | Line 135 | public class ConcurrentSkipListSubSetTes
135       * add(null) throws NPE
136       */
137      public void testAddNull() {
138 <        try {
139 <            NavigableSet q = set0();
138 >        NavigableSet<Item> q = set0();
139 >        try {
140              q.add(null);
141              shouldThrow();
142 <        } catch (NullPointerException success) { }  
142 >        } catch (NullPointerException success) {}
143      }
144  
145      /**
146       * Add of comparable element succeeds
147       */
148      public void testAdd() {
149 <        NavigableSet q = set0();
149 >        NavigableSet<Item> q = set0();
150          assertTrue(q.add(six));
151      }
152  
# Line 131 | Line 154 | public class ConcurrentSkipListSubSetTes
154       * Add of duplicate element fails
155       */
156      public void testAddDup() {
157 <        NavigableSet q = set0();
157 >        NavigableSet<Item> q = set0();
158          assertTrue(q.add(six));
159          assertFalse(q.add(six));
160      }
# Line 140 | Line 163 | public class ConcurrentSkipListSubSetTes
163       * Add of non-Comparable throws CCE
164       */
165      public void testAddNonComparable() {
166 +        ConcurrentSkipListSet<Object> src = new ConcurrentSkipListSet<>();
167 +        NavigableSet<Object> q = src.tailSet(minusOne, true);
168          try {
144            NavigableSet q = set0();
145            q.add(new Object());
169              q.add(new Object());
170              q.add(new Object());
171              shouldThrow();
172 <        }
150 <        catch(ClassCastException success) {}
172 >        } catch (ClassCastException success) {}
173      }
174  
153
175      /**
176       * addAll(null) throws NPE
177       */
178      public void testAddAll1() {
179 +        NavigableSet<Item> q = set0();
180          try {
159            NavigableSet q = set0();
181              q.addAll(null);
182              shouldThrow();
183 <        }
163 <        catch (NullPointerException success) {}
183 >        } catch (NullPointerException success) {}
184      }
185 +
186      /**
187       * addAll of a collection with null elements throws NPE
188       */
189      public void testAddAll2() {
190 +        NavigableSet<Item> q = set0();
191 +        Item[] items = new Item[SIZE];
192          try {
193 <            NavigableSet q = set0();
171 <            Integer[] ints = new Integer[SIZE];
172 <            q.addAll(Arrays.asList(ints));
193 >            q.addAll(Arrays.asList(items));
194              shouldThrow();
195 <        }
175 <        catch (NullPointerException success) {}
195 >        } catch (NullPointerException success) {}
196      }
197 +
198      /**
199       * addAll of a collection with any null elements throws NPE after
200       * possibly adding some elements
201       */
202      public void testAddAll3() {
203 +        NavigableSet<Item> q = set0();
204 +        Item[] items = new Item[2]; items[0] = zero;
205          try {
206 <            NavigableSet q = set0();
184 <            Integer[] ints = new Integer[SIZE];
185 <            for (int i = 0; i < SIZE-1; ++i)
186 <                ints[i] = new Integer(i+SIZE);
187 <            q.addAll(Arrays.asList(ints));
206 >            q.addAll(Arrays.asList(items));
207              shouldThrow();
208 <        }
190 <        catch (NullPointerException success) {}
208 >        } catch (NullPointerException success) {}
209      }
210  
211      /**
212       * Set contains all elements of successful addAll
213       */
214      public void testAddAll5() {
215 <        try {
216 <            Integer[] empty = new Integer[0];
217 <            Integer[] ints = new Integer[SIZE];
218 <            for (int i = 0; i < SIZE; ++i)
219 <                ints[i] = new Integer(SIZE-1- i);
220 <            NavigableSet q = set0();
221 <            assertFalse(q.addAll(Arrays.asList(empty)));
222 <            assertTrue(q.addAll(Arrays.asList(ints)));
223 <            for (int i = 0; i < SIZE; ++i)
206 <                assertEquals(new Integer(i), q.pollFirst());
207 <        }
208 <        finally {}
215 >        Item[] empty = new Item[0];
216 >        Item[] items = new Item[SIZE];
217 >        for (int i = 0; i < SIZE; ++i)
218 >            items[i] = itemFor(SIZE - 1 - i);
219 >        NavigableSet<Item> q = set0();
220 >        assertFalse(q.addAll(Arrays.asList(empty)));
221 >        assertTrue(q.addAll(Arrays.asList(items)));
222 >        for (int i = 0; i < SIZE; ++i)
223 >            mustEqual(i, q.pollFirst());
224      }
225  
226      /**
227       * poll succeeds unless empty
228       */
229      public void testPoll() {
230 <        NavigableSet q = populatedSet(SIZE);
230 >        NavigableSet<Item> q = populatedSet(SIZE);
231          for (int i = 0; i < SIZE; ++i) {
232 <            assertEquals(i, ((Integer)q.pollFirst()).intValue());
232 >            mustEqual(i, q.pollFirst());
233          }
234 <        assertNull(q.pollFirst());
234 >        assertNull(q.pollFirst());
235      }
236  
237      /**
238       * remove(x) removes x and returns true if present
239       */
240      public void testRemoveElement() {
241 <        NavigableSet q = populatedSet(SIZE);
242 <        for (int i = 1; i < SIZE; i+=2) {
243 <            assertTrue(q.remove(new Integer(i)));
241 >        NavigableSet<Item> q = populatedSet(SIZE);
242 >        for (int i = 1; i < SIZE; i += 2) {
243 >            mustContain(q, i);
244 >            mustRemove(q, i);
245 >            mustNotContain(q, i);
246 >            mustContain(q, i - 1);
247          }
248 <        for (int i = 0; i < SIZE; i+=2) {
249 <            assertTrue(q.remove(new Integer(i)));
250 <            assertFalse(q.remove(new Integer(i+1)));
248 >        for (int i = 0; i < SIZE; i += 2) {
249 >            mustContain(q, i);
250 >            mustRemove(q, i);
251 >            mustNotContain(q, i);
252 >            mustNotRemove(q, i + 1);
253 >            mustNotContain(q, i + 1);
254          }
255          assertTrue(q.isEmpty());
256      }
257 <        
257 >
258      /**
259       * contains(x) reports true when elements added but not yet removed
260       */
261      public void testContains() {
262 <        NavigableSet q = populatedSet(SIZE);
262 >        NavigableSet<Item> q = populatedSet(SIZE);
263          for (int i = 0; i < SIZE; ++i) {
264 <            assertTrue(q.contains(new Integer(i)));
264 >            mustContain(q, i);
265              q.pollFirst();
266 <            assertFalse(q.contains(new Integer(i)));
266 >            mustNotContain(q, i);
267          }
268      }
269  
# Line 250 | Line 271 | public class ConcurrentSkipListSubSetTes
271       * clear removes all elements
272       */
273      public void testClear() {
274 <        NavigableSet q = populatedSet(SIZE);
274 >        NavigableSet<Item> q = populatedSet(SIZE);
275          q.clear();
276          assertTrue(q.isEmpty());
277 <        assertEquals(0, q.size());
278 <        q.add(new Integer(1));
277 >        mustEqual(0, q.size());
278 >        mustAdd(q, one);
279          assertFalse(q.isEmpty());
280          q.clear();
281          assertTrue(q.isEmpty());
# Line 264 | Line 285 | public class ConcurrentSkipListSubSetTes
285       * containsAll(c) is true when c contains a subset of elements
286       */
287      public void testContainsAll() {
288 <        NavigableSet q = populatedSet(SIZE);
289 <        NavigableSet p = set0();
288 >        NavigableSet<Item> q = populatedSet(SIZE);
289 >        NavigableSet<Item> p = set0();
290          for (int i = 0; i < SIZE; ++i) {
291              assertTrue(q.containsAll(p));
292              assertFalse(p.containsAll(q));
293 <            p.add(new Integer(i));
293 >            mustAdd(p, i);
294          }
295          assertTrue(p.containsAll(q));
296      }
# Line 278 | Line 299 | public class ConcurrentSkipListSubSetTes
299       * retainAll(c) retains only those elements of c and reports true if changed
300       */
301      public void testRetainAll() {
302 <        NavigableSet q = populatedSet(SIZE);
303 <        NavigableSet p = populatedSet(SIZE);
302 >        NavigableSet<Item> q = populatedSet(SIZE);
303 >        NavigableSet<Item> p = populatedSet(SIZE);
304          for (int i = 0; i < SIZE; ++i) {
305              boolean changed = q.retainAll(p);
306              if (i == 0)
# Line 288 | Line 309 | public class ConcurrentSkipListSubSetTes
309                  assertTrue(changed);
310  
311              assertTrue(q.containsAll(p));
312 <            assertEquals(SIZE-i, q.size());
312 >            mustEqual(SIZE - i, q.size());
313              p.pollFirst();
314          }
315      }
# Line 298 | Line 319 | public class ConcurrentSkipListSubSetTes
319       */
320      public void testRemoveAll() {
321          for (int i = 1; i < SIZE; ++i) {
322 <            NavigableSet q = populatedSet(SIZE);
323 <            NavigableSet p = populatedSet(i);
322 >            NavigableSet<Item> q = populatedSet(SIZE);
323 >            NavigableSet<Item> p = populatedSet(i);
324              assertTrue(q.removeAll(p));
325 <            assertEquals(SIZE-i, q.size());
325 >            mustEqual(SIZE - i, q.size());
326              for (int j = 0; j < i; ++j) {
327 <                Integer I = (Integer)(p.pollFirst());
307 <                assertFalse(q.contains(I));
327 >                mustNotContain(q, p.pollFirst());
328              }
329          }
330      }
331  
312    
313
332      /**
333       * lower returns preceding element
334       */
335      public void testLower() {
336 <        NavigableSet q = set5();
336 >        NavigableSet<Item> q = set5();
337          Object e1 = q.lower(three);
338 <        assertEquals(two, e1);
338 >        mustEqual(two, e1);
339  
340          Object e2 = q.lower(six);
341 <        assertEquals(five, e2);
341 >        mustEqual(five, e2);
342  
343          Object e3 = q.lower(one);
344          assertNull(e3);
345  
346          Object e4 = q.lower(zero);
347          assertNull(e4);
330
348      }
349  
350      /**
351       * higher returns next element
352       */
353      public void testHigher() {
354 <        NavigableSet q = set5();
354 >        NavigableSet<Item> q = set5();
355          Object e1 = q.higher(three);
356 <        assertEquals(four, e1);
356 >        mustEqual(four, e1);
357  
358          Object e2 = q.higher(zero);
359 <        assertEquals(one, e2);
359 >        mustEqual(one, e2);
360  
361          Object e3 = q.higher(five);
362          assertNull(e3);
363  
364          Object e4 = q.higher(six);
365          assertNull(e4);
349
366      }
367  
368      /**
369       * floor returns preceding element
370       */
371      public void testFloor() {
372 <        NavigableSet q = set5();
372 >        NavigableSet<Item> q = set5();
373          Object e1 = q.floor(three);
374 <        assertEquals(three, e1);
374 >        mustEqual(three, e1);
375  
376          Object e2 = q.floor(six);
377 <        assertEquals(five, e2);
377 >        mustEqual(five, e2);
378  
379          Object e3 = q.floor(one);
380 <        assertEquals(one, e3);
380 >        mustEqual(one, e3);
381  
382          Object e4 = q.floor(zero);
383          assertNull(e4);
368
384      }
385  
386      /**
387       * ceiling returns next element
388       */
389      public void testCeiling() {
390 <        NavigableSet q = set5();
390 >        NavigableSet<Item> q = set5();
391          Object e1 = q.ceiling(three);
392 <        assertEquals(three, e1);
392 >        mustEqual(three, e1);
393  
394          Object e2 = q.ceiling(zero);
395 <        assertEquals(one, e2);
395 >        mustEqual(one, e2);
396  
397          Object e3 = q.ceiling(five);
398 <        assertEquals(five, e3);
398 >        mustEqual(five, e3);
399  
400          Object e4 = q.ceiling(six);
401          assertNull(e4);
387
402      }
403  
404      /**
405 <     * toArray contains all elements
405 >     * toArray contains all elements in sorted order
406       */
407      public void testToArray() {
408 <        NavigableSet q = populatedSet(SIZE);
409 <        Object[] o = q.toArray();
410 <        Arrays.sort(o);
411 <        for(int i = 0; i < o.length; i++)
412 <            assertEquals(o[i], q.pollFirst());
408 >        NavigableSet<Item> q = populatedSet(SIZE);
409 >        Object[] a = q.toArray();
410 >        assertSame(Object[].class, a.getClass());
411 >        for (Object o : a)
412 >            assertSame(o, q.pollFirst());
413 >        assertTrue(q.isEmpty());
414      }
415  
416      /**
417 <     * toArray(a) contains all elements
417 >     * toArray(a) contains all elements in sorted order
418       */
419      public void testToArray2() {
420 <        NavigableSet q = populatedSet(SIZE);
421 <        Integer[] ints = new Integer[SIZE];
422 <        ints = (Integer[])q.toArray(ints);
423 <        Arrays.sort(ints);
424 <        for(int i = 0; i < ints.length; i++)
425 <            assertEquals(ints[i], q.pollFirst());
420 >        NavigableSet<Item> q = populatedSet(SIZE);
421 >        Item[] items = new Item[SIZE];
422 >        Item[] array = q.toArray(items);
423 >        assertSame(items, array);
424 >        for (Item o : items)
425 >            assertSame(o, q.pollFirst());
426 >        assertTrue(q.isEmpty());
427      }
428 <    
428 >
429      /**
430       * iterator iterates through all elements
431       */
432      public void testIterator() {
433 <        NavigableSet q = populatedSet(SIZE);
434 <        int i = 0;
435 <        Iterator it = q.iterator();
436 <        while(it.hasNext()) {
433 >        NavigableSet<Item> q = populatedSet(SIZE);
434 >        Iterator<? extends Item> it = q.iterator();
435 >        int i;
436 >        for (i = 0; it.hasNext(); i++)
437              assertTrue(q.contains(it.next()));
438 <            ++i;
439 <        }
424 <        assertEquals(i, SIZE);
438 >        mustEqual(i, SIZE);
439 >        assertIteratorExhausted(it);
440      }
441  
442      /**
443       * iterator of empty set has no elements
444       */
445      public void testEmptyIterator() {
446 <        NavigableSet q = set0();
432 <        int i = 0;
433 <        Iterator it = q.iterator();
434 <        while(it.hasNext()) {
435 <            assertTrue(q.contains(it.next()));
436 <            ++i;
437 <        }
438 <        assertEquals(i, 0);
446 >        assertIteratorExhausted(set0().iterator());
447      }
448  
449      /**
450       * iterator.remove removes current element
451       */
452 <    public void testIteratorRemove () {
453 <        final NavigableSet q = set0();
454 <        q.add(new Integer(2));
455 <        q.add(new Integer(1));
456 <        q.add(new Integer(3));
457 <
450 <        Iterator it = q.iterator();
452 >    public void testIteratorRemove() {
453 >        final NavigableSet<Item> q = set0();
454 >        mustAdd(q, two);
455 >        mustAdd(q, one);
456 >        mustAdd(q, three);
457 >        Iterator<? extends Item> it = q.iterator();
458          it.next();
459          it.remove();
460  
461          it = q.iterator();
462 <        assertEquals(it.next(), new Integer(2));
463 <        assertEquals(it.next(), new Integer(3));
462 >        mustEqual(it.next(), two);
463 >        mustEqual(it.next(), three);
464          assertFalse(it.hasNext());
465      }
466  
460
467      /**
468       * toString contains toStrings of elements
469       */
470      public void testToString() {
471 <        NavigableSet q = populatedSet(SIZE);
471 >        NavigableSet<Item> q = populatedSet(SIZE);
472          String s = q.toString();
473          for (int i = 0; i < SIZE; ++i) {
474 <            assertTrue(s.indexOf(String.valueOf(i)) >= 0);
474 >            assertTrue(s.contains(String.valueOf(i)));
475          }
476 <    }        
476 >    }
477  
478      /**
479 <     * A deserialized serialized set has same elements
479 >     * A deserialized/reserialized set equals original
480       */
481 <    public void testSerialization() {
482 <        NavigableSet q = populatedSet(SIZE);
483 <        try {
484 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
485 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
486 <            out.writeObject(q);
487 <            out.close();
488 <
489 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
490 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
491 <            NavigableSet r = (NavigableSet)in.readObject();
486 <            assertEquals(q.size(), r.size());
487 <            while (!q.isEmpty())
488 <                assertEquals(q.pollFirst(), r.pollFirst());
489 <        } catch(Exception e){
490 <            e.printStackTrace();
491 <            unexpectedException();
481 >    public void testSerialization() throws Exception {
482 >        NavigableSet<Item> x = populatedSet(SIZE);
483 >        NavigableSet<Item> y = serialClone(x);
484 >
485 >        assertNotSame(y, x);
486 >        mustEqual(x.size(), y.size());
487 >        mustEqual(x, y);
488 >        mustEqual(y, x);
489 >        while (!x.isEmpty()) {
490 >            assertFalse(y.isEmpty());
491 >            mustEqual(x.pollFirst(), y.pollFirst());
492          }
493 +        assertTrue(y.isEmpty());
494      }
495  
496      /**
497       * subSet returns set with keys in requested range
498       */
499      public void testSubSetContents() {
500 <        NavigableSet set = set5();
501 <        SortedSet sm = set.subSet(two, four);
502 <        assertEquals(two, sm.first());
503 <        assertEquals(three, sm.last());
504 <        assertEquals(2, sm.size());
505 <        assertFalse(sm.contains(one));
506 <        assertTrue(sm.contains(two));
507 <        assertTrue(sm.contains(three));
508 <        assertFalse(sm.contains(four));
509 <        assertFalse(sm.contains(five));
510 <        Iterator i = sm.iterator();
511 <        Object k;
512 <        k = (Integer)(i.next());
513 <        assertEquals(two, k);
514 <        k = (Integer)(i.next());
514 <        assertEquals(three, k);
500 >        NavigableSet<Item> set = set5();
501 >        SortedSet<Item> sm = set.subSet(two, four);
502 >        mustEqual(two, sm.first());
503 >        mustEqual(three, sm.last());
504 >        mustEqual(2, sm.size());
505 >        mustNotContain(sm, one);
506 >        mustContain(sm, two);
507 >        mustContain(sm, three);
508 >        mustNotContain(sm, four);
509 >        mustNotContain(sm, five);
510 >        Iterator<? extends Item> i = sm.iterator();
511 >        Item k = i.next();
512 >        mustEqual(two, k);
513 >        k = i.next();
514 >        mustEqual(three, k);
515          assertFalse(i.hasNext());
516 <        Iterator j = sm.iterator();
516 >        Iterator<? extends Item> j = sm.iterator();
517          j.next();
518          j.remove();
519 <        assertFalse(set.contains(two));
520 <        assertEquals(4, set.size());
521 <        assertEquals(1, sm.size());
522 <        assertEquals(three, sm.first());
523 <        assertEquals(three, sm.last());
524 <        assertTrue(sm.remove(three));
519 >        mustNotContain(set, two);
520 >        mustEqual(4, set.size());
521 >        mustEqual(1, sm.size());
522 >        mustEqual(three, sm.first());
523 >        mustEqual(three, sm.last());
524 >        mustRemove(sm, three);
525          assertTrue(sm.isEmpty());
526 <        assertEquals(3, set.size());
526 >        mustEqual(3, set.size());
527      }
528  
529      public void testSubSetContents2() {
530 <        NavigableSet set = set5();
531 <        SortedSet sm = set.subSet(two, three);
532 <        assertEquals(1, sm.size());
533 <        assertEquals(two, sm.first());
534 <        assertEquals(two, sm.last());
535 <        assertFalse(sm.contains(one));
536 <        assertTrue(sm.contains(two));
537 <        assertFalse(sm.contains(three));
538 <        assertFalse(sm.contains(four));
539 <        assertFalse(sm.contains(five));
540 <        Iterator i = sm.iterator();
541 <        Object k;
542 <        k = (Integer)(i.next());
543 <        assertEquals(two, k);
530 >        NavigableSet<Item> set = set5();
531 >        SortedSet<Item> sm = set.subSet(two, three);
532 >        mustEqual(1, sm.size());
533 >        mustEqual(two, sm.first());
534 >        mustEqual(two, sm.last());
535 >        mustNotContain(sm, one);
536 >        mustContain(sm, two);
537 >        mustNotContain(sm, three);
538 >        mustNotContain(sm, four);
539 >        mustNotContain(sm, five);
540 >        Iterator<? extends Item> i = sm.iterator();
541 >        Item k = i.next();
542 >        mustEqual(two, k);
543          assertFalse(i.hasNext());
544 <        Iterator j = sm.iterator();
544 >        Iterator<? extends Item> j = sm.iterator();
545          j.next();
546          j.remove();
547 <        assertFalse(set.contains(two));
548 <        assertEquals(4, set.size());
549 <        assertEquals(0, sm.size());
547 >        mustNotContain(set, two);
548 >        mustEqual(4, set.size());
549 >        mustEqual(0, sm.size());
550          assertTrue(sm.isEmpty());
551          assertFalse(sm.remove(three));
552 <        assertEquals(4, set.size());
552 >        mustEqual(4, set.size());
553      }
554  
555      /**
556       * headSet returns set with keys in requested range
557       */
558      public void testHeadSetContents() {
559 <        NavigableSet set = set5();
560 <        SortedSet sm = set.headSet(four);
561 <        assertTrue(sm.contains(one));
562 <        assertTrue(sm.contains(two));
563 <        assertTrue(sm.contains(three));
564 <        assertFalse(sm.contains(four));
565 <        assertFalse(sm.contains(five));
566 <        Iterator i = sm.iterator();
567 <        Object k;
568 <        k = (Integer)(i.next());
569 <        assertEquals(one, k);
570 <        k = (Integer)(i.next());
571 <        assertEquals(two, k);
572 <        k = (Integer)(i.next());
574 <        assertEquals(three, k);
559 >        NavigableSet<Item> set = set5();
560 >        SortedSet<Item> sm = set.headSet(four);
561 >        mustContain(sm, one);
562 >        mustContain(sm, two);
563 >        mustContain(sm, three);
564 >        mustNotContain(sm, four);
565 >        mustNotContain(sm, five);
566 >        Iterator<? extends Item> i = sm.iterator();
567 >        Item k = i.next();
568 >        mustEqual(one, k);
569 >        k = i.next();
570 >        mustEqual(two, k);
571 >        k = i.next();
572 >        mustEqual(three, k);
573          assertFalse(i.hasNext());
574          sm.clear();
575          assertTrue(sm.isEmpty());
576 <        assertEquals(2, set.size());
577 <        assertEquals(four, set.first());
576 >        mustEqual(2, set.size());
577 >        mustEqual(four, set.first());
578      }
579  
580      /**
581       * tailSet returns set with keys in requested range
582       */
583      public void testTailSetContents() {
584 <        NavigableSet set = set5();
585 <        SortedSet sm = set.tailSet(two);
584 >        NavigableSet<Item> set = set5();
585 >        SortedSet<Item> sm = set.tailSet(two);
586 >        mustNotContain(sm, one);
587 >        mustContain(sm, two);
588 >        mustContain(sm, three);
589 >        mustContain(sm, four);
590 >        mustContain(sm, five);
591          assertFalse(sm.contains(one));
592          assertTrue(sm.contains(two));
593          assertTrue(sm.contains(three));
594          assertTrue(sm.contains(four));
595          assertTrue(sm.contains(five));
596 <        Iterator i = sm.iterator();
597 <        Object k;
598 <        k = (Integer)(i.next());
599 <        assertEquals(two, k);
600 <        k = (Integer)(i.next());
601 <        assertEquals(three, k);
602 <        k = (Integer)(i.next());
603 <        assertEquals(four, k);
604 <        k = (Integer)(i.next());
605 <        assertEquals(five, k);
596 >        Iterator<? extends Item> i = sm.iterator();
597 >        Item k = i.next();
598 >        mustEqual(two, k);
599 >        k = i.next();
600 >        mustEqual(three, k);
601 >        k = i.next();
602 >        mustEqual(four, k);
603 >        k = i.next();
604 >        mustEqual(five, k);
605 >        assertFalse(i.hasNext());
606 >
607 >        SortedSet<Item> ssm = sm.tailSet(four);
608 >        mustEqual(four, ssm.first());
609 >        mustEqual(five, ssm.last());
610 >        mustRemove(ssm, four);
611 >        mustEqual(1, ssm.size());
612 >        mustEqual(3, sm.size());
613 >        mustEqual(4, set.size());
614 >    }
615 >
616 >    /**
617 >     * size changes when elements added and removed
618 >     */
619 >    public void testDescendingSize() {
620 >        NavigableSet<Item> q = populatedSet(SIZE);
621 >        for (int i = 0; i < SIZE; ++i) {
622 >            mustEqual(SIZE - i, q.size());
623 >            q.pollFirst();
624 >        }
625 >        for (int i = 0; i < SIZE; ++i) {
626 >            mustEqual(i, q.size());
627 >            mustAdd(q, i);
628 >        }
629 >    }
630 >
631 >    /**
632 >     * add(null) throws NPE
633 >     */
634 >    public void testDescendingAddNull() {
635 >        NavigableSet<Item> q = dset0();
636 >        try {
637 >            q.add(null);
638 >            shouldThrow();
639 >        } catch (NullPointerException success) {}
640 >    }
641 >
642 >    /**
643 >     * Add of comparable element succeeds
644 >     */
645 >    public void testDescendingAdd() {
646 >        NavigableSet<Item> q = dset0();
647 >        assertTrue(q.add(minusSix));
648 >    }
649 >
650 >    /**
651 >     * Add of duplicate element fails
652 >     */
653 >    public void testDescendingAddDup() {
654 >        NavigableSet<Item> q = dset0();
655 >        assertTrue(q.add(minusSix));
656 >        assertFalse(q.add(minusSix));
657 >    }
658 >
659 >    /**
660 >     * Add of non-Comparable throws CCE
661 >     */
662 >    public void testDescendingAddNonComparable() {
663 >        NavigableSet<Object> q = new ConcurrentSkipListSet<>();
664 >        try {
665 >            q.add(new Object());
666 >            q.add(new Object());
667 >            shouldThrow();
668 >        } catch (ClassCastException success) {}
669 >    }
670 >
671 >    /**
672 >     * addAll(null) throws NPE
673 >     */
674 >    public void testDescendingAddAll1() {
675 >        NavigableSet<Item> q = dset0();
676 >        try {
677 >            q.addAll(null);
678 >            shouldThrow();
679 >        } catch (NullPointerException success) {}
680 >    }
681 >
682 >    /**
683 >     * addAll of a collection with null elements throws NPE
684 >     */
685 >    public void testDescendingAddAll2() {
686 >        NavigableSet<Item> q = dset0();
687 >        Item[] items = new Item[1];
688 >        try {
689 >            q.addAll(Arrays.asList(items));
690 >            shouldThrow();
691 >        } catch (NullPointerException success) {}
692 >    }
693 >
694 >    /**
695 >     * addAll of a collection with any null elements throws NPE after
696 >     * possibly adding some elements
697 >     */
698 >    public void testDescendingAddAll3() {
699 >        NavigableSet<Item> q = dset0();
700 >        Item[] items = new Item[2]; items[0] = zero;
701 >        try {
702 >            q.addAll(Arrays.asList(items));
703 >            shouldThrow();
704 >        } catch (NullPointerException success) {}
705 >    }
706 >
707 >    /**
708 >     * Set contains all elements of successful addAll
709 >     */
710 >    public void testDescendingAddAll5() {
711 >        Item[] empty = new Item[0];
712 >        Item[] items = new Item[SIZE];
713 >        for (int i = 0; i < SIZE; ++i)
714 >            items[i] = itemFor(SIZE - 1 - i);
715 >        NavigableSet<Item> q = dset0();
716 >        assertFalse(q.addAll(Arrays.asList(empty)));
717 >        assertTrue(q.addAll(Arrays.asList(items)));
718 >        for (int i = 0; i < SIZE; ++i)
719 >            mustEqual(i, q.pollFirst());
720 >    }
721 >
722 >    /**
723 >     * poll succeeds unless empty
724 >     */
725 >    public void testDescendingPoll() {
726 >        NavigableSet<Item> q = populatedSet(SIZE);
727 >        for (int i = 0; i < SIZE; ++i) {
728 >            mustEqual(i, q.pollFirst());
729 >        }
730 >        assertNull(q.pollFirst());
731 >    }
732 >
733 >    /**
734 >     * remove(x) removes x and returns true if present
735 >     */
736 >    public void testDescendingRemoveElement() {
737 >        NavigableSet<Item> q = populatedSet(SIZE);
738 >        for (int i = 1; i < SIZE; i += 2) {
739 >            mustRemove(q, i);
740 >        }
741 >        for (int i = 0; i < SIZE; i += 2 ) {
742 >            mustRemove(q, i);
743 >            mustNotRemove(q, i + 1);
744 >        }
745 >        assertTrue(q.isEmpty());
746 >    }
747 >
748 >    /**
749 >     * contains(x) reports true when elements added but not yet removed
750 >     */
751 >    public void testDescendingContains() {
752 >        NavigableSet<Item> q = populatedSet(SIZE);
753 >        for (int i = 0; i < SIZE; ++i) {
754 >            mustContain(q, i);
755 >            q.pollFirst();
756 >            mustNotContain(q, i);
757 >        }
758 >    }
759 >
760 >    /**
761 >     * clear removes all elements
762 >     */
763 >    public void testDescendingClear() {
764 >        NavigableSet<Item> q = populatedSet(SIZE);
765 >        q.clear();
766 >        assertTrue(q.isEmpty());
767 >        mustEqual(0, q.size());
768 >        mustAdd(q, one);
769 >        assertFalse(q.isEmpty());
770 >        q.clear();
771 >        assertTrue(q.isEmpty());
772 >    }
773 >
774 >    /**
775 >     * containsAll(c) is true when c contains a subset of elements
776 >     */
777 >    public void testDescendingContainsAll() {
778 >        NavigableSet<Item> q = populatedSet(SIZE);
779 >        NavigableSet<Item> p = dset0();
780 >        for (int i = 0; i < SIZE; ++i) {
781 >            assertTrue(q.containsAll(p));
782 >            assertFalse(p.containsAll(q));
783 >            mustAdd(p, i);
784 >        }
785 >        assertTrue(p.containsAll(q));
786 >    }
787 >
788 >    /**
789 >     * retainAll(c) retains only those elements of c and reports true if changed
790 >     */
791 >    public void testDescendingRetainAll() {
792 >        NavigableSet<Item> q = populatedSet(SIZE);
793 >        NavigableSet<Item> p = populatedSet(SIZE);
794 >        for (int i = 0; i < SIZE; ++i) {
795 >            boolean changed = q.retainAll(p);
796 >            if (i == 0)
797 >                assertFalse(changed);
798 >            else
799 >                assertTrue(changed);
800 >
801 >            assertTrue(q.containsAll(p));
802 >            mustEqual(SIZE - i, q.size());
803 >            p.pollFirst();
804 >        }
805 >    }
806 >
807 >    /**
808 >     * removeAll(c) removes only those elements of c and reports true if changed
809 >     */
810 >    public void testDescendingRemoveAll() {
811 >        for (int i = 1; i < SIZE; ++i) {
812 >            NavigableSet<Item> q = populatedSet(SIZE);
813 >            NavigableSet<Item> p = populatedSet(i);
814 >            assertTrue(q.removeAll(p));
815 >            mustEqual(SIZE - i, q.size());
816 >            for (int j = 0; j < i; ++j) {
817 >                mustNotContain(q, p.pollFirst());
818 >            }
819 >        }
820 >    }
821 >
822 >    /**
823 >     * lower returns preceding element
824 >     */
825 >    public void testDescendingLower() {
826 >        NavigableSet<Item> q = dset5();
827 >        Object e1 = q.lower(minusThree);
828 >        mustEqual(minusTwo, e1);
829 >
830 >        Object e2 = q.lower(minusSix);
831 >        mustEqual(minusFive, e2);
832 >
833 >        Object e3 = q.lower(minusOne);
834 >        assertNull(e3);
835 >
836 >        Object e4 = q.lower(zero);
837 >        assertNull(e4);
838 >    }
839 >
840 >    /**
841 >     * higher returns next element
842 >     */
843 >    public void testDescendingHigher() {
844 >        NavigableSet<Item> q = dset5();
845 >        Object e1 = q.higher(minusThree);
846 >        mustEqual(minusFour, e1);
847 >
848 >        Object e2 = q.higher(zero);
849 >        mustEqual(minusOne, e2);
850 >
851 >        Object e3 = q.higher(minusFive);
852 >        assertNull(e3);
853 >
854 >        Object e4 = q.higher(minusSix);
855 >        assertNull(e4);
856 >    }
857 >
858 >    /**
859 >     * floor returns preceding element
860 >     */
861 >    public void testDescendingFloor() {
862 >        NavigableSet<Item> q = dset5();
863 >        Object e1 = q.floor(minusThree);
864 >        mustEqual(minusThree, e1);
865 >
866 >        Object e2 = q.floor(minusSix);
867 >        mustEqual(minusFive, e2);
868 >
869 >        Object e3 = q.floor(minusOne);
870 >        mustEqual(minusOne, e3);
871 >
872 >        Object e4 = q.floor(zero);
873 >        assertNull(e4);
874 >    }
875 >
876 >    /**
877 >     * ceiling returns next element
878 >     */
879 >    public void testDescendingCeiling() {
880 >        NavigableSet<Item> q = dset5();
881 >        Object e1 = q.ceiling(minusThree);
882 >        mustEqual(minusThree, e1);
883 >
884 >        Object e2 = q.ceiling(zero);
885 >        mustEqual(minusOne, e2);
886 >
887 >        Object e3 = q.ceiling(minusFive);
888 >        mustEqual(minusFive, e3);
889 >
890 >        Object e4 = q.ceiling(minusSix);
891 >        assertNull(e4);
892 >    }
893 >
894 >    /**
895 >     * toArray contains all elements
896 >     */
897 >    public void testDescendingToArray() {
898 >        NavigableSet<Item> q = populatedSet(SIZE);
899 >        Object[] o = q.toArray();
900 >        Arrays.sort(o);
901 >        for (int i = 0; i < o.length; i++)
902 >            mustEqual(o[i], q.pollFirst());
903 >    }
904 >
905 >    /**
906 >     * toArray(a) contains all elements
907 >     */
908 >    public void testDescendingToArray2() {
909 >        NavigableSet<Item> q = populatedSet(SIZE);
910 >        Item[] items = new Item[SIZE];
911 >        assertSame(items, q.toArray(items));
912 >        Arrays.sort(items);
913 >        for (int i = 0; i < items.length; i++)
914 >            mustEqual(items[i], q.pollFirst());
915 >    }
916 >
917 >    /**
918 >     * iterator iterates through all elements
919 >     */
920 >    public void testDescendingIterator() {
921 >        NavigableSet<Item> q = populatedSet(SIZE);
922 >        int i = 0;
923 >        Iterator<? extends Item> it = q.iterator();
924 >        while (it.hasNext()) {
925 >            mustContain(q, it.next());
926 >            ++i;
927 >        }
928 >        mustEqual(i, SIZE);
929 >    }
930 >
931 >    /**
932 >     * iterator of empty set has no elements
933 >     */
934 >    public void testDescendingEmptyIterator() {
935 >        NavigableSet<Item> q = dset0();
936 >        int i = 0;
937 >        Iterator<? extends Item> it = q.iterator();
938 >        while (it.hasNext()) {
939 >            mustContain(q, it.next());
940 >            ++i;
941 >        }
942 >        mustEqual(0, i);
943 >    }
944 >
945 >    /**
946 >     * iterator.remove removes current element
947 >     */
948 >    public void testDescendingIteratorRemove() {
949 >        final NavigableSet<Item> q = dset0();
950 >        q.add(two);
951 >        q.add(one);
952 >        q.add(three);
953 >
954 >        Iterator<? extends Item> it = q.iterator();
955 >        it.next();
956 >        it.remove();
957 >
958 >        it = q.iterator();
959 >        mustEqual(it.next(), two);
960 >        mustEqual(it.next(), three);
961 >        assertFalse(it.hasNext());
962 >    }
963 >
964 >    /**
965 >     * toString contains toStrings of elements
966 >     */
967 >    public void testDescendingToString() {
968 >        NavigableSet<Item> q = populatedSet(SIZE);
969 >        String s = q.toString();
970 >        for (int i = 0; i < SIZE; ++i) {
971 >            assertTrue(s.contains(String.valueOf(i)));
972 >        }
973 >    }
974 >
975 >    /**
976 >     * A deserialized/reserialized set equals original
977 >     */
978 >    public void testDescendingSerialization() throws Exception {
979 >        NavigableSet<Item> x = dset5();
980 >        NavigableSet<Item> y = serialClone(x);
981 >
982 >        assertNotSame(y, x);
983 >        mustEqual(x.size(), y.size());
984 >        mustEqual(x, y);
985 >        mustEqual(y, x);
986 >        while (!x.isEmpty()) {
987 >            assertFalse(y.isEmpty());
988 >            mustEqual(x.pollFirst(), y.pollFirst());
989 >        }
990 >        assertTrue(y.isEmpty());
991 >    }
992 >
993 >    /**
994 >     * subSet returns set with keys in requested range
995 >     */
996 >    public void testDescendingSubSetContents() {
997 >        NavigableSet<Item> set = dset5();
998 >        SortedSet<Item> sm = set.subSet(minusTwo, minusFour);
999 >        mustEqual(minusTwo, sm.first());
1000 >        mustEqual(minusThree, sm.last());
1001 >        mustEqual(2, sm.size());
1002 >        mustNotContain(sm, minusOne);
1003 >        mustContain(sm, minusTwo);
1004 >        mustContain(sm, minusThree);
1005 >        mustNotContain(sm, minusFour);
1006 >        mustNotContain(sm, minusFive);
1007 >        Iterator<? extends Item> i = sm.iterator();
1008 >        Item k = i.next();
1009 >        mustEqual(minusTwo, k);
1010 >        k = i.next();
1011 >        mustEqual(minusThree, k);
1012 >        assertFalse(i.hasNext());
1013 >        Iterator<? extends Item> j = sm.iterator();
1014 >        j.next();
1015 >        j.remove();
1016 >        mustNotContain(set, minusTwo);
1017 >        mustEqual(4, set.size());
1018 >        mustEqual(1, sm.size());
1019 >        mustEqual(minusThree, sm.first());
1020 >        mustEqual(minusThree, sm.last());
1021 >        mustRemove(sm, minusThree);
1022 >        assertTrue(sm.isEmpty());
1023 >        mustEqual(3, set.size());
1024 >    }
1025 >
1026 >    public void testDescendingSubSetContents2() {
1027 >        NavigableSet<Item> set = dset5();
1028 >        SortedSet<Item> sm = set.subSet(minusTwo, minusThree);
1029 >        mustEqual(1, sm.size());
1030 >        mustEqual(minusTwo, sm.first());
1031 >        mustEqual(minusTwo, sm.last());
1032 >        mustNotContain(sm, minusOne);
1033 >        mustContain(sm, minusTwo);
1034 >        mustNotContain(sm, minusThree);
1035 >        mustNotContain(sm, minusFour);
1036 >        mustNotContain(sm, minusFive);
1037 >        Iterator<? extends Item> i = sm.iterator();
1038 >        Item k = i.next();
1039 >        mustEqual(minusTwo, k);
1040 >        assertFalse(i.hasNext());
1041 >        Iterator<? extends Item> j = sm.iterator();
1042 >        j.next();
1043 >        j.remove();
1044 >        mustNotContain(set, minusTwo);
1045 >        mustEqual(4, set.size());
1046 >        mustEqual(0, sm.size());
1047 >        assertTrue(sm.isEmpty());
1048 >        mustNotRemove(sm, minusThree);
1049 >        mustEqual(4, set.size());
1050 >    }
1051 >
1052 >    /**
1053 >     * headSet returns set with keys in requested range
1054 >     */
1055 >    public void testDescendingHeadSetContents() {
1056 >        NavigableSet<Item> set = dset5();
1057 >        SortedSet<Item> sm = set.headSet(minusFour);
1058 >        mustContain(sm, minusOne);
1059 >        mustContain(sm, minusTwo);
1060 >        mustContain(sm, minusThree);
1061 >        mustNotContain(sm, minusFour);
1062 >        mustNotContain(sm, minusFive);
1063 >        Iterator<? extends Item> i = sm.iterator();
1064 >        Item k = i.next();
1065 >        mustEqual(minusOne, k);
1066 >        k = i.next();
1067 >        mustEqual(minusTwo, k);
1068 >        k = i.next();
1069 >        mustEqual(minusThree, k);
1070 >        assertFalse(i.hasNext());
1071 >        sm.clear();
1072 >        assertTrue(sm.isEmpty());
1073 >        mustEqual(2, set.size());
1074 >        mustEqual(minusFour, set.first());
1075 >    }
1076 >
1077 >    /**
1078 >     * tailSet returns set with keys in requested range
1079 >     */
1080 >    public void testDescendingTailSetContents() {
1081 >        NavigableSet<Item> set = dset5();
1082 >        SortedSet<Item> sm = set.tailSet(minusTwo);
1083 >        mustNotContain(sm, minusOne);
1084 >        mustContain(sm, minusTwo);
1085 >        mustContain(sm, minusThree);
1086 >        mustContain(sm, minusFour);
1087 >        mustContain(sm, minusFive);
1088 >        Iterator<? extends Item> i = sm.iterator();
1089 >        Item k = i.next();
1090 >        mustEqual(minusTwo, k);
1091 >        k = i.next();
1092 >        mustEqual(minusThree, k);
1093 >        k = i.next();
1094 >        mustEqual(minusFour, k);
1095 >        k = i.next();
1096 >        mustEqual(minusFive, k);
1097          assertFalse(i.hasNext());
1098  
1099 <        SortedSet ssm = sm.tailSet(four);
1100 <        assertEquals(four, ssm.first());
1101 <        assertEquals(five, ssm.last());
1102 <        assertTrue(ssm.remove(four));
1103 <        assertEquals(1, ssm.size());
1104 <        assertEquals(3, sm.size());
1105 <        assertEquals(4, set.size());
1099 >        SortedSet<Item> ssm = sm.tailSet(minusFour);
1100 >        mustEqual(minusFour, ssm.first());
1101 >        mustEqual(minusFive, ssm.last());
1102 >        mustRemove(ssm, minusFour);
1103 >        mustEqual(1, ssm.size());
1104 >        mustEqual(3, sm.size());
1105 >        mustEqual(4, set.size());
1106      }
1107  
1108   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines