Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbrun2012-09-18 15:34:13 -0400
committercbrun2012-09-18 15:34:13 -0400
commitaa853d65192e333965bf663dbea7c61fe2523835 (patch)
treeb831afdd02585ba58d7483ac2daa1bb51127deb3 /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff
parent4669384219377edf6efff4f4caf2cc9804293885 (diff)
downloadorg.eclipse.emf.compare-aa853d65192e333965bf663dbea7c61fe2523835.tar.gz
org.eclipse.emf.compare-aa853d65192e333965bf663dbea7c61fe2523835.tar.xz
org.eclipse.emf.compare-aa853d65192e333965bf663dbea7c61fe2523835.zip
We should not use stat similarity to compare URIs
No more using the classical "string similarity" algorithm based on the dice coefficient to compare URIs. Introduces a specific implementation comparing URIs or fragments spliting the path and comparing those.
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/URIDistanceTest.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/URIDistanceTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/URIDistanceTest.java
new file mode 100644
index 000000000..43051bdcb
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/URIDistanceTest.java
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2012 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ */
+package org.eclipse.emf.compare.tests.diff;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.emf.compare.match.eobject.URIDistance;
+import org.junit.Test;
+
+public class URIDistanceTest {
+
+ private URIDistance meter = new URIDistance();
+
+ @Test
+ public void sameNumberOfFragments() throws Exception {
+ assertEquals(3, meter.proximity("/root/a/b", "/root/a/b/c"));
+ assertEquals(3, meter.proximity("/root/a/b/", "/root/a/b/c/"));
+ assertEquals(0, meter.proximity("/root/a/b", "/root/a/b"));
+ assertEquals(8, meter.proximity("/root/a/a2/a3", "/root/b/b2/a3"));
+ assertEquals(8, meter.proximity("/root/a/a2/a3", "/root/b/b2/b3"));
+ }
+
+ @Test
+ public void identics() throws Exception {
+ assertEquals(0, meter.proximity("/root/a/b/", "/root/a/b/"));
+ assertEquals(0, meter.proximity("/root/", "/root/"));
+ assertEquals(0, meter.proximity("", ""));
+ }
+
+ @Test
+ public void limitCases() throws Exception {
+ assertEquals(0, meter.proximity("", ""));
+ assertEquals(10, meter.proximity("",
+ "/a/very/long/path/just/to/check/we/wont/ends/up/with/a/weird/thing"));
+ }
+
+ @Test
+ public void completelyDifferent() throws Exception {
+ assertEquals(10, meter.proximity("/c/d/e/", "/root/a/b/"));
+ assertEquals(10, meter.proximity("/c/", "/root/a/b/"));
+ assertEquals(10, meter.proximity("/c/d/e", "/root/"));
+ assertEquals(10, meter.proximity("/c/d/e/f", "/a/b/e/f"));
+ assertEquals(10, meter.proximity("/a", "/b"));
+ }
+
+ @Test
+ public void orderMatters() throws Exception {
+ assertEquals(10, meter.proximity("/c/d/e/f", "/f/d/c/e"));
+ }
+
+ @Test
+ public void idLikeURIs() throws Exception {
+ assertEquals(10, meter.proximity("#131233", "#azeazezae"));
+ assertEquals(3, meter.proximity("/c/d/e/f", "/c/d/e/f?#azeaze"));
+ }
+
+ @Test
+ public void traillingSlashes() throws Exception {
+ assertEquals(3, meter.proximity("/root/a/b/", "/root/a/b/c/"));
+ assertEquals(3, meter.proximity("root/a/b/", "/root/a/b/c/"));
+ assertEquals(3, meter.proximity("/root/a/b/", "/root/a/b/c"));
+ assertEquals(3, meter.proximity("///root/a/b/", "/root/a/b/c"));
+ }
+
+}

Back to the top