1 16 package org.apache.commons.collections.set; 17 18 import java.util.Iterator ; 19 import java.util.Set ; 20 21 import junit.framework.Test; 22 import junit.framework.TestSuite; 23 24 import org.apache.commons.collections.map.LinkedMap; 25 26 34 public class TestMapBackedSet2 extends AbstractTestSet { 35 36 public TestMapBackedSet2(String testName) { 37 super(testName); 38 } 39 40 public static Test suite() { 41 return new TestSuite(TestMapBackedSet2.class); 42 } 43 44 public static void main(String args[]) { 45 String [] testCaseName = { TestMapBackedSet2.class.getName()}; 46 junit.textui.TestRunner.main(testCaseName); 47 } 48 49 public Set makeEmptySet() { 50 return MapBackedSet.decorate(new LinkedMap()); 51 } 52 53 protected Set setupSet() { 54 Set set = makeEmptySet(); 55 56 for (int i = 0; i < 10; i++) { 57 set.add(Integer.toString(i)); 58 } 59 return set; 60 } 61 62 public void testOrdering() { 63 Set set = setupSet(); 64 Iterator it = set.iterator(); 65 66 for (int i = 0; i < 10; i++) { 67 assertEquals("Sequence is wrong", Integer.toString(i), it.next()); 68 } 69 70 for (int i = 0; i < 10; i += 2) { 71 assertTrue("Must be able to remove int", set.remove(Integer.toString(i))); 72 } 73 74 it = set.iterator(); 75 for (int i = 1; i < 10; i += 2) { 76 assertEquals("Sequence is wrong after remove ", Integer.toString(i), it.next()); 77 } 78 79 for (int i = 0; i < 10; i++) { 80 set.add(Integer.toString(i)); 81 } 82 83 assertEquals("Size of set is wrong!", 10, set.size()); 84 85 it = set.iterator(); 86 for (int i = 1; i < 10; i += 2) { 87 assertEquals("Sequence is wrong", Integer.toString(i), it.next()); 88 } 89 for (int i = 0; i < 10; i += 2) { 90 assertEquals("Sequence is wrong", Integer.toString(i), it.next()); 91 } 92 } 93 94 public void testCanonicalEmptyCollectionExists() { 95 } 96 97 public void testCanonicalFullCollectionExists() { 98 } 99 100 } 101 | Popular Tags |