Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2015-05-12 08:39:05 +0000
committerAxel Richard2015-05-13 07:59:58 +0000
commit6719de0f862809a32d0ed902ad0eb645bd84e985 (patch)
treeaf447e55a89804e6e5c13ae24d277ecc11efa264 /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils
parent0c29d5db83bea1868aabfac3fb44d30ef95fc05e (diff)
downloadorg.eclipse.emf.compare-6719de0f862809a32d0ed902ad0eb645bd84e985.tar.gz
org.eclipse.emf.compare-6719de0f862809a32d0ed902ad0eb645bd84e985.tar.xz
org.eclipse.emf.compare-6719de0f862809a32d0ed902ad0eb645bd84e985.zip
[458971] Fix infinite loop in Graph.BreadthFirstIterator#prune()
Bug: 458971 Change-Id: I1134d05a996d1f1a80cac27829250e6e9b732d02 Signed-off-by: Axel Richard <axel.richard@obeo.fr>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/GraphTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/GraphTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/GraphTest.java
index 01cf4ddd8..b8ab011ee 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/GraphTest.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/GraphTest.java
@@ -19,6 +19,7 @@ import com.google.common.collect.Lists;
import java.util.Set;
import org.eclipse.emf.compare.internal.utils.Graph;
+import org.eclipse.emf.compare.internal.utils.PruningIterator;
import org.junit.Test;
/**
@@ -53,4 +54,30 @@ public class GraphTest {
assertEquals(4, subgraph.size());
assertTrue(subgraph.containsAll(Lists.newArrayList("a", "b", "d", "f")));
}
+
+ /*
+ * Just to avoid infinite loop in prune.
+ */
+ @Test
+ public void testPrune() {
+ Graph<String> graph = new Graph<String>();
+ //@formatter:off
+ /*
+ * Add the following graph:
+ * c-\
+ * | |
+ * b-/
+ * |
+ * a
+ */
+ //@formatter:on
+ graph.addChildren("a", ImmutableSet.of("b"));
+ graph.addChildren("b", ImmutableSet.of("c"));
+ graph.addChildren("c", ImmutableSet.of("b"));
+ PruningIterator<String> iterator = graph.breadthFirstIterator();
+ while (iterator.hasNext()) {
+ iterator.next();
+ iterator.prune();
+ }
+ }
}

Back to the top