GeezerVison is showing github.com — included some more tests · dandycheung/java-diff-utils@0545519
File treeExpand file treeCollapse file tree Open diff view settings resources/com/github/difflib/text
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: java-diff-utils/src/test/java/com/github/difflib/patch/PatchWithMeyerDiffTest.java +17Lines changed: 17 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 16 | 16 | package com.github.difflib.patch; | 17 | 17 |
| 18 | 18 | import com.github.difflib.DiffUtils; | | 19 | +import static com.github.difflib.patch.Patch.CONFLICT_PRODUCES_MERGE_CONFLICT; | 19 | 20 | import java.util.Arrays; | 20 | 21 | import java.util.List; | | 22 | +import static java.util.stream.Collectors.joining; | 21 | 23 | import static org.junit.jupiter.api.Assertions.assertEquals; | 22 | 24 | import static org.junit.jupiter.api.Assertions.fail; | 23 | 25 | import org.junit.jupiter.api.Test; | | 27 | 29 | * @author tw | 28 | 30 | */ | 29 | 31 | public class PatchWithMeyerDiffTest { | | 32 | + | 30 | 33 | @Test | 31 | 34 | public void testPatch_Change_withExceptionProcessor() { | 32 | 35 | final List<String> changeTest_from = Arrays.asList("aaa", "bbb", "ccc", "ddd"); | @@ -48,4 +51,18 @@ public void testPatch_Change_withExceptionProcessor() { | 48 | 51 | fail(e.getMessage()); | 49 | 52 | } | 50 | 53 | } | | 54 | + | | 55 | + @Test | | 56 | + public void testPatchThreeWayIssue138() throws PatchFailedException { | | 57 | + List<String> base = Arrays.asList("Imagine there's no heaven".split("\\s+")); | | 58 | + List<String> left = Arrays.asList("Imagine there's no HEAVEN".split("\\s+")); | | 59 | + List<String> right = Arrays.asList("IMAGINE there's no heaven".split("\\s+")); | | 60 | + | | 61 | + Patch<String> rightPatch = DiffUtils.diff(base, right) | | 62 | + .withConflictOutput(CONFLICT_PRODUCES_MERGE_CONFLICT); | | 63 | + | | 64 | + List<String> applied = rightPatch.applyTo(left); | | 65 | + | | 66 | + assertEquals("IMAGINE there's no HEAVEN", applied.stream().collect(joining(" "))); | | 67 | + } | 51 | 68 | } |
Collapse file Copy file name to clipboardExpand all lines: java-diff-utils/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -761,4 +761,28 @@ public void testIssue129SkipDeltaDecompression() { | 761 | 761 |
| 762 | 762 | assertThat(txt).isEqualTo("EQUAL EQUAL EQUAL CHANGE CHANGE CHANGE EQUAL EQUAL EQUAL"); | 763 | 763 | } | | 764 | + | | 765 | + @Test | | 766 | + public void testIssue129SkipWhitespaceChanges() throws IOException { | | 767 | + String original = Files.lines(Paths.get("target/test-classes/com/github/difflib/text/issue129_1.txt")).collect(joining("\n")); | | 768 | + String revised = Files.lines(Paths.get("target/test-classes/com/github/difflib/text/issue129_2.txt")).collect(joining("\n")); | | 769 | + | | 770 | + DiffRowGenerator generator = DiffRowGenerator.create() | | 771 | + .showInlineDiffs(true) | | 772 | + .mergeOriginalRevised(true) | | 773 | + .inlineDiffByWord(true) | | 774 | + .ignoreWhiteSpaces(true) | | 775 | + .oldTag((tag, isOpening) -> isOpening ? "==old" + tag + "==>" : "<==old==") | | 776 | + .newTag((tag, isOpening) -> isOpening ? "==new" + tag + "==>" : "<==new==") | | 777 | + .build(); | | 778 | + List<DiffRow> rows = generator.generateDiffRows( | | 779 | + Arrays.asList(original.split("\n")), | | 780 | + Arrays.asList(revised.split("\n"))); | | 781 | + | | 782 | + assertThat(rows).hasSize(13); | | 783 | + | | 784 | + rows.stream() | | 785 | + .filter(item -> item.getTag() != DiffRow.Tag.EQUAL) | | 786 | + .forEach(System.out::println); | | 787 | + } | 764 | 788 | } |
Collapse file Copy file name to clipboard +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated | | 2 | +to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or | | 3 | +any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to | | 4 | +dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. | | 5 | +It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate -- we can not | | 6 | +consecrate -- we can not hallow -- this ground. The brave men, living and dead, who struggled here, have consecrated it, | | 7 | +far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never | | 8 | +forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought | | 9 | +here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -- that | | 10 | +from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that | | 11 | +we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of | | 12 | +freedom -- and that government of the people, by the people, for the people, shall not perish from the earth. |
Collapse file Copy file name to clipboard +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and | | 2 | +dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether | | 3 | +that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that | | 4 | +war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives | | 5 | +that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we | | 6 | +can not dedicate -- we can not consecrate -- we can not hallow -- this ground. The brave men, living and dead, who | | 7 | +struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long | | 8 | +remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated | | 9 | +here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here | | 10 | +dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause | | 11 | +for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died | | 12 | +in vain -- that this nation, under God, shall have a new birth of freedom -- and that government of the people, by the | | 13 | +people, for the people, shall not perish from the earth. |
|