commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r332769 - /jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestListOrderedSet.java
Date Sat, 12 Nov 2005 12:40:05 GMT
Author: scolebourne
Date: Sat Nov 12 04:40:01 2005
New Revision: 332769

URL: http://svn.apache.org/viewcvs?rev=332769&view=rev
Log:
Improve tests
from 37338

Modified:
    jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestListOrderedSet.java

Modified: jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestListOrderedSet.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestListOrderedSet.java?rev=332769&r1=332768&r2=332769&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestListOrderedSet.java
(original)
+++ jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestListOrderedSet.java
Sat Nov 12 04:40:01 2005
@@ -130,7 +130,6 @@
     
     public void testListAddIndexed() {
         ListOrderedSet set = (ListOrderedSet) makeEmptySet();
-        List view = set.asList();
         set.add(ZERO);
         set.add(TWO);
         
@@ -164,6 +163,38 @@
         assertSame(THREE, set.get(1));
         assertSame(TWO, set.get(2));
         assertSame(ONE, set.get(3));
+    }
+
+    public void testListAddReplacing() {
+        ListOrderedSet set = (ListOrderedSet) makeEmptySet();
+        A a = new A();
+        B b = new B();
+        set.add(a);
+        assertEquals(1, set.size());
+        set.add(b);  // will match but not replace A as equal
+        assertEquals(1, set.size());
+        assertSame(a, set.getSet().iterator().next());
+        assertSame(a, set.iterator().next());
+        assertSame(a, set.get(0));
+        assertSame(a, set.asList().get(0));
+    }
+
+    static class A {
+        public boolean equals(Object obj) {
+            return (obj instanceof A || obj instanceof B);
+        }
+        public int hashCode() {
+            return 1;
+        }
+    }
+
+    static class B {
+        public boolean equals(Object obj) {
+            return (obj instanceof A || obj instanceof B);
+        }
+        public int hashCode() {
+            return 1;
+        }
     }
 
     public void testDecorator() {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message