Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2014-09-19 14:17:33 +0000
committerAxel Richard2014-09-19 14:17:33 +0000
commit00e1d6a77311080f908aaff026343636ef001188 (patch)
treef1595839b491a251dd0b37a71e6ec1abaed1729d /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf
parent8b51e776ff2cfd9e91c627d77044c973e8cd2942 (diff)
downloadorg.eclipse.emf.compare-00e1d6a77311080f908aaff026343636ef001188.tar.gz
org.eclipse.emf.compare-00e1d6a77311080f908aaff026343636ef001188.tar.xz
org.eclipse.emf.compare-00e1d6a77311080f908aaff026343636ef001188.zip
[444351] Fix bug in EqualityHelper.matchingArrays
EqualityHelper.matchingArrays now returns false for arrays of different lengths Add very basic tests for EqualityHelper.matchingValues Bug: 444351 Change-Id: I569e3f0bae796fbb8d2cc35196f550480ce25516 Signed-off-by: Axel Richard <axel.richard@obeo.fr>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java3
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/EqualityHelperTest.java105
2 files changed, 107 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
index c3f00530f..1fc8520dc 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/suite/AllTests.java
@@ -47,6 +47,7 @@ import org.eclipse.emf.compare.tests.postprocess.PostProcessorTest;
import org.eclipse.emf.compare.tests.rcp.AllRCPTests;
import org.eclipse.emf.compare.tests.req.ReqComputingTest;
import org.eclipse.emf.compare.tests.scope.DefaultComparisonScopeTest;
+import org.eclipse.emf.compare.tests.utils.EqualityHelperTest;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.junit.BeforeClass;
@@ -69,7 +70,7 @@ import org.junit.runners.Suite.SuiteClasses;
AllEditTests.class, CommandStackTestSuite.class, MatchEngineFactoryRegistryTest.class,
ConflictMergeTest.class, PseudoConflictMergeTest.class, ProximityIndexTest.class, AllRCPTests.class,
FeatureMaps2wayMergeTest.class, FeatureMaps3wayMergeTest.class, FeatureMapsConflictsMergeTest.class,
- FeatureMapsPseudoConflictsMergeTest.class, TwoWayBatchMergingTest.class })
+ FeatureMapsPseudoConflictsMergeTest.class, TwoWayBatchMergingTest.class, EqualityHelperTest.class })
public class AllTests {
/**
* Standalone launcher for all of compare's tests.
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/EqualityHelperTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/EqualityHelperTest.java
new file mode 100644
index 000000000..b5eb6111f
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/EqualityHelperTest.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.utils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.emf.compare.tests.nodes.NodesPackage;
+import org.eclipse.emf.compare.utils.EqualityHelper;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.ecore.util.FeatureMap.Entry;
+import org.junit.Test;
+
+/**
+ * We will use this to test the utility methods exposed by the {@link EqualityHelper}.
+ *
+ * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
+ */
+@SuppressWarnings("all")
+public class EqualityHelperTest {
+
+ @Test
+ public void matchingValues() {
+ final EqualityHelper helper = new EqualityHelper(null);
+ final Object o1 = new Object();
+ final Object o2 = new Object();
+
+ assertFalse(helper.matchingValues(o1, o2));
+ assertTrue(helper.matchingValues(o1, o1));
+
+ assertTrue(helper.matchingValues("", null));
+ assertTrue(helper.matchingValues(null, ""));
+ assertTrue(helper.matchingValues("a", "a"));
+ assertTrue(helper.matchingValues(new Integer(42), new Integer(42)));
+ assertTrue(helper.matchingValues(new Boolean(true), new Boolean(true)));
+
+ final String[] array1 = {"a", "b", "c" };
+ final String[] array2 = {"d", "e", "f" };
+ final String[] array3 = {"a", "b", "c", "d" };
+ final String[] array4 = {"d", "c", "b", "a" };
+
+ assertTrue(helper.matchingValues(array1, array1));
+ assertFalse(helper.matchingValues(array1, array2));
+ assertFalse(helper.matchingValues(array1, array3));
+ assertFalse(helper.matchingValues(array3, array4));
+
+ final FeatureMap.Entry entry1 = new Entry() {
+
+ public Object getValue() {
+ return new Integer(42);
+ }
+
+ public EStructuralFeature getEStructuralFeature() {
+ return NodesPackage.eINSTANCE.getNode_Name();
+ }
+ };
+
+ final FeatureMap.Entry entry2 = new Entry() {
+
+ public Object getValue() {
+ return new Integer(24);
+ }
+
+ public EStructuralFeature getEStructuralFeature() {
+ return NodesPackage.eINSTANCE.getNode_Name();
+ }
+ };
+
+ final FeatureMap.Entry entry3 = new Entry() {
+
+ public Object getValue() {
+ return new Integer(42);
+ }
+
+ public EStructuralFeature getEStructuralFeature() {
+ return NodesPackage.eINSTANCE.getNode_ContainmentRef1();
+ }
+ };
+
+ final FeatureMap.Entry entry4 = new Entry() {
+
+ public Object getValue() {
+ return new Integer(24);
+ }
+
+ public EStructuralFeature getEStructuralFeature() {
+ return NodesPackage.eINSTANCE.getNode_ContainmentRef1();
+ }
+ };
+
+ assertTrue(helper.matchingValues(entry1, entry1));
+ assertFalse(helper.matchingValues(entry1, entry2));
+ assertFalse(helper.matchingValues(entry1, entry3));
+ assertFalse(helper.matchingValues(entry2, entry4));
+ }
+}

Back to the top