GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — introduced a more complicated test which can only be solved using the… · chabicht/java-diff-utils@f955268

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • java-diff-utils/src
    • main/java/com/github/difflib/algorithm/myers
      • MyersDiff.java
      • MyersDiffWithLinearSpace.java
    • test
      • java/com/github/difflib/text
        • DiffRowGeneratorTest.java
      • resources/com/github/difflib/text
        • test.zip
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java‎

Copy file name to clipboardExpand all lines: java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ public static DiffAlgorithmFactory factory() {
187187
@Override
188188
public <T> DiffAlgorithmI<T>
189189
create() {
190-
return new MyersDiff<T>();
190+
return new MyersDiff<>();
191191
}
192192

193193
@Override
194194
public <T> DiffAlgorithmI<T>
195195
create(BiPredicate < T, T > equalizer) {
196-
return new MyersDiff<T>(equalizer);
196+
return new MyersDiff<>(equalizer);
197197
}
198198
};
199199
}
Collapse file

‎java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiffWithLinearSpace.java‎

Copy file name to clipboardExpand all lines: java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiffWithLinearSpace.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ public static DiffAlgorithmFactory factory() {
231231
@Override
232232
public <T> DiffAlgorithmI<T>
233233
create() {
234-
return new MyersDiffWithLinearSpace<T>();
234+
return new MyersDiffWithLinearSpace<>();
235235
}
236236

237237
@Override
238238
public <T> DiffAlgorithmI<T>
239239
create(BiPredicate < T, T > equalizer) {
240-
return new MyersDiffWithLinearSpace<T>(equalizer);
240+
return new MyersDiffWithLinearSpace<>(equalizer);
241241
}
242242
};
243243
}
Collapse file

‎java-diff-utils/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java‎

Copy file name to clipboardExpand all lines: java-diff-utils/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java
+43-14Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package com.github.difflib.text;
22

3+
import com.github.difflib.DiffUtils;
4+
import com.github.difflib.algorithm.myers.MyersDiffWithLinearSpace;
35
import java.io.File;
46
import java.io.IOException;
7+
import java.net.URISyntaxException;
8+
import java.nio.file.FileSystem;
9+
import java.nio.file.FileSystems;
510
import java.nio.file.Files;
611
import java.nio.file.Paths;
712
import java.util.Arrays;
@@ -721,7 +726,7 @@ public void testIssue129WithDeltaDecompression() {
721726

722727
assertThat(txt).isEqualTo("EQUAL EQUAL EQUAL CHANGE INSERT INSERT EQUAL EQUAL EQUAL");
723728
}
724-
729+
725730
@Test
726731
public void testIssue129SkipDeltaDecompression() {
727732
List<String> lines1 = Arrays.asList(
@@ -743,25 +748,25 @@ public void testIssue129SkipDeltaDecompression() {
743748
"banana2",
744749
"banana3");
745750
int[] entry = {1};
746-
String txt =
747-
DiffRowGenerator.create()
748-
.showInlineDiffs(true)
749-
.decompressDeltas(false)
750-
.oldTag((tag, isOpening) -> isOpening ? "==old" + tag + "==>" : "<==old==")
751-
.newTag((tag, isOpening) -> isOpening ? "==new" + tag + "==>" : "<==new==")
752-
.build()
753-
.generateDiffRows(lines1, lines2)
754-
.stream()
755-
.map(row -> row.getTag().toString())
756-
.collect(joining(" "));
751+
String txt
752+
= DiffRowGenerator.create()
753+
.showInlineDiffs(true)
754+
.decompressDeltas(false)
755+
.oldTag((tag, isOpening) -> isOpening ? "==old" + tag + "==>" : "<==old==")
756+
.newTag((tag, isOpening) -> isOpening ? "==new" + tag + "==>" : "<==new==")
757+
.build()
758+
.generateDiffRows(lines1, lines2)
759+
.stream()
760+
.map(row -> row.getTag().toString())
761+
.collect(joining(" "));
757762
// .forEachOrdered(row -> {
758763
// System.out.printf("%4d %-8s %-80s %-80s\n", entry[0]++,
759764
// row.getTag(), row.getOldLine(), row.getNewLine());
760765
// });
761766

762767
assertThat(txt).isEqualTo("EQUAL EQUAL EQUAL CHANGE CHANGE CHANGE EQUAL EQUAL EQUAL");
763768
}
764-
769+
765770
@Test
766771
public void testIssue129SkipWhitespaceChanges() throws IOException {
767772
String original = Files.lines(Paths.get("target/test-classes/com/github/difflib/text/issue129_1.txt")).collect(joining("\n"));
@@ -780,9 +785,33 @@ public void testIssue129SkipWhitespaceChanges() throws IOException {
780785
Arrays.asList(revised.split("\n")));
781786

782787
assertThat(rows).hasSize(13);
783-
788+
784789
rows.stream()
785790
.filter(item -> item.getTag() != DiffRow.Tag.EQUAL)
786791
.forEach(System.out::println);
787792
}
793+
794+
@Test
795+
public void testIssue188HangOnExamples() throws IOException, URISyntaxException {
796+
try (FileSystem zipFs = FileSystems.newFileSystem(Paths.get("target/test-classes/com/github/difflib/text/test.zip"), null);) {
797+
List<String> original = Files.readAllLines(zipFs.getPath("old.html"));
798+
List<String> revised = Files.readAllLines(zipFs.getPath("new.html"));
799+
800+
DiffRowGenerator generator = DiffRowGenerator.create()
801+
.lineNormalizer(line -> line)
802+
.showInlineDiffs(true)
803+
.mergeOriginalRevised(true)
804+
.inlineDiffByWord(true)
805+
.decompressDeltas(true)
806+
.oldTag(f -> f ? "<s style=\"background-color: #bbbbbb\">" : "</s>")
807+
.newTag(f -> f ? "<b style=\"background-color: #aaffaa\">" : "</b>")
808+
.build();
809+
810+
//List<DiffRow> rows = generator.generateDiffRows(original, revised);
811+
List<DiffRow> rows = generator.generateDiffRows(original, DiffUtils.diff(original, revised, new MyersDiffWithLinearSpace<>() ));
812+
813+
System.out.println(rows);
814+
}
815+
}
788816
}
817+
Collapse file

‎java-diff-utils/src/test/resources/com/github/difflib/text/test.zip‎

Copy file name to clipboard
108 KB
Binary file not shown.

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.