diff options
author | Shawn Pearce <spearce@spearce.org> | 2017-04-04 22:26:35 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2017-04-04 22:26:38 -0400 |
commit | db2493e7d8198021c789c9f96ca7a8c0c01c8488 (patch) | |
tree | 3d870d0886f1b3abe4a33c2004954b855472efba /org.eclipse.jgit.test | |
parent | cab9dee333513ad428d151ac4a6db00173fb6113 (diff) | |
parent | 4a985f5aa858a71561d55c9eb3ce007768c4d0c0 (diff) | |
download | jgit-db2493e7d8198021c789c9f96ca7a8c0c01c8488.tar.gz jgit-db2493e7d8198021c789c9f96ca7a8c0c01c8488.zip |
Merge "Make diff locations more consistent"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java | 26 | ||||
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java | 39 |
2 files changed, 65 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java index b8f8dcb5ad..4130b7ee5b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java @@ -196,6 +196,32 @@ public abstract class AbstractDiffTestCase { } @Test + public void testEdit_DeleteNearCommonTail() { + EditList r = diff(t("aCq}nD}nb"), t("aq}nb")); + assertEquals(new Edit(1, 2, 1, 1), r.get(0)); + assertEquals(new Edit(5, 8, 4, 4), r.get(1)); + assertEquals(2, r.size()); + } + + @Test + public void testEdit_DeleteNearCommonCenter() { + EditList r = diff(t("abcd123123uvwxpq"), t("aBcd123uvwxPq")); + assertEquals(new Edit(1, 2, 1, 2), r.get(0)); + assertEquals(new Edit(7, 10, 7, 7), r.get(1)); + assertEquals(new Edit(14, 15, 11, 12), r.get(2)); + assertEquals(3, r.size()); + } + + @Test + public void testEdit_InsertNearCommonCenter() { + EditList r = diff(t("aBcd123uvwxPq"), t("abcd123123uvwxpq")); + assertEquals(new Edit(1, 2, 1, 2), r.get(0)); + assertEquals(new Edit(7, 7, 7, 10), r.get(1)); + assertEquals(new Edit(11, 12, 14, 15), r.get(2)); + assertEquals(3, r.size()); + } + + @Test public void testEdit_LinuxBug() { EditList r = diff(t("a{bcdE}z"), t("a{0bcdEE}z")); assertEquals(new Edit(2, 2, 2, 3), r.get(0)); 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 d4a3d62dad..5af62b6704 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 @@ -132,6 +132,45 @@ public class MergeAlgorithmTest { } /** + * Merge two modifications with a shared delete at the end. The underlying + * diff algorithm has to provide consistent edit results to get the expected + * merge result. + * + * @throws IOException + */ + @Test + public void testTwoModificationsWithSharedDelete() throws IOException { + assertEquals(t("Cb}n}"), + merge("ab}n}n}", "ab}n}", "Cb}n}")); + } + + /** + * Merge modifications with a shared insert in the middle. The + * underlying diff algorithm has to provide consistent edit + * results to get the expected merge result. + * + * @throws IOException + */ + @Test + public void testModificationsWithMiddleInsert() throws IOException { + assertEquals(t("aBcd123123uvwxPq"), + merge("abcd123uvwxpq", "aBcd123123uvwxPq", "abcd123123uvwxpq")); + } + + /** + * Merge modifications with a shared delete in the middle. The + * underlying diff algorithm has to provide consistent edit + * results to get the expected merge result. + * + * @throws IOException + */ + @Test + public void testModificationsWithMiddleDelete() throws IOException { + assertEquals(t("Abz}z123Q"), + merge("abz}z}z123q", "Abz}z123Q", "abz}z123q")); + } + + /** * Test a conflicting region at the very start of the text. * * @throws IOException |