Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2012-06-01 10:30:22 -0400
committerlgoubet2012-06-01 10:30:22 -0400
commite34a3cb41081eba0c137e3bf4eec3d36946d66c7 (patch)
treed8c0d887adcd12a8178ba6bb59beee5f6212ce1b /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff
parentd2aaf203678a693848c3ba35728c662578ca1e6b (diff)
downloadorg.eclipse.emf.compare-e34a3cb41081eba0c137e3bf4eec3d36946d66c7.tar.gz
org.eclipse.emf.compare-e34a3cb41081eba0c137e3bf4eec3d36946d66c7.tar.xz
org.eclipse.emf.compare-e34a3cb41081eba0c137e3bf4eec3d36946d66c7.zip
React to changes introduced by CBR with the EqualityHelper
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/DiffUtilTest.java124
1 files changed, 83 insertions, 41 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/DiffUtilTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/DiffUtilTest.java
index a4ff76ed4..9c75ad4ff 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/DiffUtilTest.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/diff/DiffUtilTest.java
@@ -20,6 +20,7 @@ import java.util.List;
import org.eclipse.emf.compare.CompareFactory;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.utils.DiffUtil;
+import org.eclipse.emf.compare.utils.EqualityHelper;
import org.junit.Test;
/**
@@ -35,7 +36,8 @@ public class DiffUtilTest {
final List<Character> right = Lists.charactersOf("czdab");
final Comparison emptyComparison = CompareFactory.eINSTANCE.createComparison();
- final List<Character> lcs = DiffUtil.longestCommonSubsequence(emptyComparison, left, right);
+ final List<Character> lcs = DiffUtil.longestCommonSubsequence(emptyComparison, new EqualityHelper(),
+ left, right);
/*
* This is documented in {@link DefaultDiffEngine#longestCommonSubsequence(Comparison, List, List)}.
@@ -50,7 +52,8 @@ public class DiffUtilTest {
final List<Character> right = Lists.charactersOf("ycdeb");
final Comparison emptyComparison = CompareFactory.eINSTANCE.createComparison();
- final List<Character> lcs = DiffUtil.longestCommonSubsequence(emptyComparison, left, right);
+ final List<Character> lcs = DiffUtil.longestCommonSubsequence(emptyComparison, new EqualityHelper(),
+ left, right);
/*
* This is documented in {@link DefaultDiffEngine#longestCommonSubsequence(Comparison, List, List)}.
@@ -65,7 +68,8 @@ public class DiffUtilTest {
final List<Integer> right = Lists.newArrayList(8, 9, 2, 3, 4, 1, 0);
final Comparison emptyComparison = CompareFactory.eINSTANCE.createComparison();
- final List<Integer> lcs = DiffUtil.longestCommonSubsequence(emptyComparison, left, right);
+ final List<Integer> lcs = DiffUtil.longestCommonSubsequence(emptyComparison, new EqualityHelper(),
+ left, right);
// These are the origin and left sides of the "complex" conflict test case.
assertEqualContents(Lists.newArrayList(2, 3, 4), lcs);
@@ -77,7 +81,8 @@ public class DiffUtilTest {
final List<Integer> right = Lists.newArrayList(6, 2, 9, 3, 0, 4, 1, 7);
final Comparison emptyComparison = CompareFactory.eINSTANCE.createComparison();
- final List<Integer> lcs = DiffUtil.longestCommonSubsequence(emptyComparison, left, right);
+ final List<Integer> lcs = DiffUtil.longestCommonSubsequence(emptyComparison, new EqualityHelper(),
+ left, right);
// These are the origin and right sides of the "complex" conflict test case.
assertEqualContents(Lists.newArrayList(2, 3, 4, 7), lcs);
@@ -108,25 +113,29 @@ public class DiffUtilTest {
// Merge the move of "1" (assume 1 already removed from right)
List<Integer> right = Lists.newArrayList(6, 2, 9, 3, 0, 4, 7);
- int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(1));
+ int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(1));
// Inserted just before "0"
assertSame(Integer.valueOf(4), Integer.valueOf(insertionIndex));
// Merge the move of "9" (assume 9 already removed from right)
right = Lists.newArrayList(6, 2, 3, 1, 0, 4, 7);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(9));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(9));
// Inserted just before "2"
assertSame(Integer.valueOf(1), Integer.valueOf(insertionIndex));
// Merge the move of "0" (assume 0 already removed from right)
right = Lists.newArrayList(6, 9, 2, 3, 1, 4, 7);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
// Inserted just before "4"
assertSame(Integer.valueOf(5), Integer.valueOf(insertionIndex));
// merge the addition of "8"
right = Lists.newArrayList(6, 9, 2, 3, 1, 0, 4, 7);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(8));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(8));
// Inserted just before "9"
assertSame(Integer.valueOf(1), Integer.valueOf(insertionIndex));
@@ -134,13 +143,15 @@ public class DiffUtilTest {
// merge the move of "4" (assume already removed from right)
right = Lists.newArrayList(6, 8, 9, 2, 3, 1, 0);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(4));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(4));
// Inserted just after "3"
assertSame(Integer.valueOf(5), Integer.valueOf(insertionIndex));
// merge the move of "6" (assume already removed from right)
right = Lists.newArrayList(8, 9, 2, 3, 4, 1, 0);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(6));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(6));
// Inserted just after "0"
assertSame(Integer.valueOf(7), Integer.valueOf(insertionIndex));
}
@@ -154,15 +165,18 @@ public class DiffUtilTest {
final Integer expectedIndex = Integer.valueOf(right.size());
List<Integer> left = Lists.newArrayList(0, 1, 2, 3);
- int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(1, 0, 2, 3);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(1, 2, 3, 0);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
}
@@ -175,31 +189,38 @@ public class DiffUtilTest {
final Integer expectedIndex = Integer.valueOf(0);
List<Integer> left = Lists.newArrayList(0, 1, 2, 3);
- int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(0, 4, 1, 2, 3);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(4, 0, 1, 2, 3);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(4, 0, 5, 1, 2, 3);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(4, 0, 5, 1, 2, 3, 6);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(4, 0, 5, 1, 6, 2, 3);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(4, 0, 5, 1, 6, 2, 7, 8, 3, 9);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
}
@@ -213,21 +234,24 @@ public class DiffUtilTest {
List<Integer> right = Lists.newArrayList(4, 1, 2, 3);
// Start of LCS is 1
Integer expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(1)));
- int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(0, 6, 1, 5, 2, 4, 3);
right = Lists.newArrayList(7, 4, 1, 2, 3, 8);
// Start of LCS is 1
expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(1)));
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(5, 0, 6, 7, 1, 2, 4, 3);
right = Lists.newArrayList(7, 4, 1, 2, 9, 3, 8);
// Start of LCS is 7
expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(7)));
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
}
@@ -240,31 +264,38 @@ public class DiffUtilTest {
final Integer expectedIndex = Integer.valueOf(right.size());
List<Integer> left = Lists.newArrayList(1, 2, 3, 0);
- int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(1, 2, 3, 4, 0);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(1, 2, 3, 0, 4);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(1, 2, 3, 5, 0, 4);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(6, 1, 2, 3, 5, 0, 4);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(1, 6, 2, 3, 5, 0, 4);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(9, 1, 6, 2, 7, 8, 3, 5, 0, 4);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
}
@@ -278,21 +309,24 @@ public class DiffUtilTest {
List<Integer> right = Lists.newArrayList(1, 2, 3, 4);
// End of LCS is 3
Integer expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(3)) + 1);
- int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(1, 5, 2, 4, 3, 6, 0);
right = Lists.newArrayList(8, 1, 2, 3, 4, 7);
// End of LCS is 3
expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(3)) + 1);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(1, 2, 4, 3, 7, 6, 0, 5);
right = Lists.newArrayList(8, 1, 2, 9, 3, 4, 7);
// End of LCS is 7
expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(7)) + 1);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
}
@@ -306,31 +340,36 @@ public class DiffUtilTest {
List<Integer> left = Lists.newArrayList(1, 0, 2, 3);
// Closest LCS element "before" is 1
int expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(1)) + 1);
- int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(1, 2, 0, 3, 4);
// Closest LCS element "before" is 2
expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(2)) + 1);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(1, 0, 4, 2, 3);
// Closest LCS element "before" is 1
expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(1)) + 1);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(5, 1, 4, 2, 0, 3);
// Closest LCS element "before" is 2
expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(2)) + 1);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(6, 1, 7, 8, 0, 9, 2, 10, 3, 5, 4);
// Closest LCS element "before" is 1
expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(1)) + 1);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
}
@@ -344,14 +383,16 @@ public class DiffUtilTest {
List<Integer> right = Lists.newArrayList(1, 2, 3, 4);
// Closest LCS element is 2
Integer expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(2)) + 1);
- int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ int insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
left = Lists.newArrayList(1, 5, 2, 4, 0, 3, 6);
right = Lists.newArrayList(8, 1, 2, 3, 4, 7);
// Closest LCS element is 2
expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(2)) + 1);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
/*
@@ -362,7 +403,8 @@ public class DiffUtilTest {
right = Lists.newArrayList(8, 1, 2, 9, 3, 4, 7);
// Closest LCS element is 3
expectedIndex = Integer.valueOf(right.indexOf(Integer.valueOf(3)) + 1);
- insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, left, right, Integer.valueOf(0));
+ insertionIndex = DiffUtil.findInsertionIndex(emptyComparison, new EqualityHelper(), left, right,
+ Integer.valueOf(0));
assertSame(expectedIndex, Integer.valueOf(insertionIndex));
}

Back to the top