Add test case for DualTreeBidiMap sort order
bug 29519, from Jonas Van Poucke git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131792 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
50b6e166f7
commit
57a6f158f4
|
@ -239,6 +239,9 @@
|
|||
<contributor>
|
||||
<name>Ilkka Priha</name>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Jonas Van Poucke</name>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Herve Quiroz</name>
|
||||
</contributor>
|
||||
|
|
|
@ -20,6 +20,10 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
|
@ -35,10 +39,11 @@ import org.apache.commons.collections.comparators.ReverseComparator;
|
|||
/**
|
||||
* JUnit tests.
|
||||
*
|
||||
* @version $Revision: 1.1 $ $Date: 2004/06/11 23:29:07 $
|
||||
* @version $Revision: 1.2 $ $Date: 2004/06/21 22:30:05 $
|
||||
*
|
||||
* @author Matthew Hawthorne
|
||||
* @author Stephen Colebourne
|
||||
* @author Jonas Van Poucke
|
||||
*/
|
||||
public class TestDualTreeBidiMap2 extends AbstractTestSortedBidiMap {
|
||||
|
||||
|
@ -88,6 +93,25 @@ public class TestDualTreeBidiMap2 extends AbstractTestSortedBidiMap {
|
|||
}
|
||||
}
|
||||
|
||||
public void testSortOrder() throws Exception {
|
||||
SortedBidiMap sm = (SortedBidiMap) makeFullMap();
|
||||
|
||||
// Sort by the comparator used in the makeEmptyBidiMap() method
|
||||
List newSortedKeys = Arrays.asList(getSampleKeys());
|
||||
Collections.sort(newSortedKeys, new ReverseComparator(ComparableComparator.getInstance()));
|
||||
newSortedKeys = Collections.unmodifiableList(newSortedKeys);
|
||||
|
||||
Iterator mapIter = sm.keySet().iterator();
|
||||
Iterator expectedIter = newSortedKeys.iterator();
|
||||
while (expectedIter.hasNext()) {
|
||||
Object expectedKey = expectedIter.next();
|
||||
Object mapKey = mapIter.next();
|
||||
assertNotNull("key in sorted list may not be null", expectedKey);
|
||||
assertNotNull("key in map may not be null", mapKey);
|
||||
assertEquals("key from sorted list and map must be equal", expectedKey, mapKey);
|
||||
}
|
||||
}
|
||||
|
||||
public String getCompatibilityVersion() {
|
||||
return "3.Test2";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue