You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/11/08 19:00:27 UTC

commons-collections git commit: [COLLECTIONS-701] SetUniqueList.add() crashes due to infinite recursion.

Repository: commons-collections
Updated Branches:
  refs/heads/master d8fd53176 -> a424d2ff1


[COLLECTIONS-701] SetUniqueList.add() crashes due to infinite recursion.

Add tests.

Project: http://git-wip-us.apache.org/repos/asf/commons-collections/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-collections/commit/a424d2ff
Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/tree/a424d2ff
Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/diff/a424d2ff

Branch: refs/heads/master
Commit: a424d2ff172aa3be9eb5155e732e6f61915d7b5e
Parents: d8fd531
Author: Gary Gregory <ga...@gmail.com>
Authored: Thu Nov 8 12:00:23 2018 -0700
Committer: Gary Gregory <ga...@gmail.com>
Committed: Thu Nov 8 12:00:23 2018 -0700

----------------------------------------------------------------------
 .../collections4/list/Collections701Test.java   | 42 ++++++++++++++++++++
 1 file changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-collections/blob/a424d2ff/src/test/java/org/apache/commons/collections4/list/Collections701Test.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/collections4/list/Collections701Test.java b/src/test/java/org/apache/commons/collections4/list/Collections701Test.java
new file mode 100644
index 0000000..f0b92f7
--- /dev/null
+++ b/src/test/java/org/apache/commons/collections4/list/Collections701Test.java
@@ -0,0 +1,42 @@
+package org.apache.commons.collections4.list;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Tests for COLLECTIONS-701.
+ */
+public class Collections701Test {
+
+    @Test
+    public void testArrayList() {
+        final List<Object> list = new ArrayList<>();
+        list.add(list);
+        Assert.assertEquals(1, list.size());
+        Assert.assertEquals(list, list.get(0));
+    }
+
+    @Test
+    public void testHashSet() {
+        final Set<Object> set = new HashSet<>();
+        set.add(set);
+        Assert.assertEquals(1, set.size());
+        Assert.assertEquals(set, set.iterator().next());
+    }
+
+    @Test
+    @Ignore
+    public void testSetUniqueList() {
+        final List<Object> source = new ArrayList<>();
+        final List<Object> list = SetUniqueList.setUniqueList(source);
+        list.add(list);
+        Assert.assertEquals(1, list.size());
+        Assert.assertEquals(list, list.get(0));
+    }
+}