aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2011-05-17 08:54:18 -0400
committerCode Review <codereview-daemon@eclipse.org>2011-05-17 08:54:18 -0400
commitd781554b79b50e5c3fe468373e87edf8957d7578 (patch)
tree319c8f4409ac53987b7aba8cdc3813aff1c9f6a9 /org.eclipse.jgit.test
parentb13ca9121b8f2c6a0ebca1a2a12c4af7e75dfd20 (diff)
parent0461ff4f0c7ef505c818dac95286fa852f16eef7 (diff)
downloadjgit-d781554b79b50e5c3fe468373e87edf8957d7578.tar.gz
jgit-d781554b79b50e5c3fe468373e87edf8957d7578.zip
Merge "Optimize MergeAlgorithm if ours or theirs is empty"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java
index aa8f8281e4..8a33425b1d 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java
@@ -198,6 +198,25 @@ public class MergeAlgorithmTest {
}
+ /**
+ * Test situations where (at least) one input value is the empty text
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testEmptyTexts() throws IOException {
+ // test modification against deletion
+ assertEquals(t("<AB=>"), merge("A", "AB", ""));
+ assertEquals(t("<=AB>"), merge("A", "", "AB"));
+
+ // test unmodified against deletion
+ assertEquals(t(""), merge("AB", "AB", ""));
+ assertEquals(t(""), merge("AB", "", "AB"));
+
+ // test deletion against deletion
+ assertEquals(t(""), merge("AB", "", ""));
+ }
+
private String merge(String commonBase, String ours, String theirs) throws IOException {
MergeResult r = new MergeAlgorithm().merge(RawTextComparator.DEFAULT,
T(commonBase), T(ours), T(theirs));
@@ -231,5 +250,4 @@ public class MergeAlgorithmTest {
public static RawText T(String text) {
return new RawText(Constants.encode(t(text)));
}
-
}