Skip to content

Commit d04f43e

Browse files
committed
1 parent 134f80f commit d04f43e

File tree

5 files changed

+6
-81
lines changed

5 files changed

+6
-81
lines changed

src/main/java/com/github/difflib/algorithm/jgit/JGitDiff.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public List<Change> diff(List<T> original, List<T> revised) throws DiffException
4444
diffList.addAll(new HistogramDiff().diff(new DataListComparator<>(), new DataList<>(original), new DataList<>(revised)));
4545
List<Change> patch = new ArrayList<>();
4646
for (Edit edit : diffList) {
47-
DeltaType type = DeltaType.EQUAL;
47+
DeltaType type;
4848
switch (edit.getType()) {
4949
case DELETE:
5050
type = DeltaType.DELETE;
@@ -55,6 +55,8 @@ public List<Change> diff(List<T> original, List<T> revised) throws DiffException
5555
case REPLACE:
5656
type = DeltaType.CHANGE;
5757
break;
58+
default:
59+
type = DeltaType.EQUAL;
5860
}
5961
patch.add(new Change(type,edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB()));
6062
}

src/main/java/com/github/difflib/text/DiffRowGenerator.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
*/
5050
public class DiffRowGenerator {
5151

52+
public static final BiPredicate<String,String> IGNORE_WHITESPACE_EQUALIZER = (original, revised)
53+
-> original.trim().replaceAll("\\s+", " ").equals(revised.trim().replaceAll("\\s+", " "));
54+
public static final BiPredicate<String,String> DEFAULT_EQUALIZER = Object::equals;
5255
private static final Pattern SPLIT_PATTERN = Pattern.compile("\\s+|[,.\\[\\](){}/\\\\*+\\-#]");
5356
private final boolean showInlineDiffs;
5457
private final boolean ignoreWhiteSpaces;
@@ -171,10 +174,6 @@ public Builder inlineDiffByWord(boolean inlineDiffByWord) {
171174
public static Builder create() {
172175
return new Builder();
173176
}
174-
175-
public static final BiPredicate<String,String> IGNORE_WHITESPACE_EQUALIZER = (original, revised)
176-
-> original.trim().replaceAll("\\s+", " ").equals(revised.trim().replaceAll("\\s+", " "));
177-
public static final BiPredicate<String,String> DEFAULT_EQUALIZER = Object::equals;
178177

179178
private DiffRowGenerator(Builder builder) {
180179
showInlineDiffs = builder.showInlineDiffs;

src/test/java/com/github/difflib/algorithm/jgit/JGitDiffTest.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,11 @@
1515
*/
1616
package com.github.difflib.algorithm.jgit;
1717

18-
import com.github.difflib.algorithm.jgit.JGitDiff;
19-
import static com.github.difflib.DiffUtilsTest.readStringListFromInputStream;
20-
import com.github.difflib.TestConstants;
2118
import com.github.difflib.algorithm.DiffException;
2219
import com.github.difflib.patch.Patch;
2320
import com.github.difflib.patch.PatchFailedException;
24-
import java.io.IOException;
2521
import java.util.Arrays;
2622
import java.util.List;
27-
import java.util.zip.ZipFile;
28-
import org.junit.After;
29-
import org.junit.AfterClass;
30-
import org.junit.Before;
31-
import org.junit.BeforeClass;
3223
import org.junit.Test;
3324
import static org.junit.Assert.*;
3425

@@ -37,29 +28,7 @@
3728
* @author toben
3829
*/
3930
public class JGitDiffTest {
40-
41-
public JGitDiffTest() {
42-
}
43-
44-
@BeforeClass
45-
public static void setUpClass() {
46-
}
47-
48-
@AfterClass
49-
public static void tearDownClass() {
50-
}
51-
52-
@Before
53-
public void setUp() {
54-
}
55-
56-
@After
57-
public void tearDown() {
58-
}
5931

60-
/**
61-
* Test of diff method, of class JGitDiff.
62-
*/
6332
@Test
6433
public void testDiff() throws DiffException, PatchFailedException {
6534
List<String> orgList = Arrays.asList("A","B","C","A","B","B","A");

src/test/java/com/github/difflib/algorithm/jgit/LRJGitDiffTest.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,14 @@
1515
*/
1616
package com.github.difflib.algorithm.jgit;
1717

18-
import com.github.difflib.algorithm.jgit.JGitDiff;
1918
import static com.github.difflib.DiffUtilsTest.readStringListFromInputStream;
2019
import com.github.difflib.TestConstants;
2120
import com.github.difflib.algorithm.DiffException;
2221
import com.github.difflib.patch.Patch;
2322
import com.github.difflib.patch.PatchFailedException;
2423
import java.io.IOException;
25-
import java.util.Arrays;
2624
import java.util.List;
2725
import java.util.zip.ZipFile;
28-
import org.junit.After;
29-
import org.junit.AfterClass;
30-
import org.junit.Before;
31-
import org.junit.BeforeClass;
3226
import org.junit.Test;
3327
import static org.junit.Assert.*;
3428

@@ -38,26 +32,6 @@
3832
*/
3933
public class LRJGitDiffTest {
4034

41-
public LRJGitDiffTest() {
42-
}
43-
44-
@BeforeClass
45-
public static void setUpClass() {
46-
}
47-
48-
@AfterClass
49-
public static void tearDownClass() {
50-
}
51-
52-
@Before
53-
public void setUp() {
54-
}
55-
56-
@After
57-
public void tearDown() {
58-
}
59-
60-
6135
@Test
6236
public void testPossibleDiffHangOnLargeDatasetDnaumenkoIssue26() throws IOException, DiffException, PatchFailedException {
6337
ZipFile zip = new ZipFile(TestConstants.MOCK_FOLDER + "/large_dataset1.zip");

src/test/java/com/github/difflib/algorithm/myers/MyersDiffTest.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,6 @@
3434
*/
3535
public class MyersDiffTest {
3636

37-
public MyersDiffTest() {
38-
}
39-
40-
@BeforeClass
41-
public static void setUpClass() {
42-
}
43-
44-
@AfterClass
45-
public static void tearDownClass() {
46-
}
47-
48-
@Before
49-
public void setUp() {
50-
}
51-
52-
@After
53-
public void tearDown() {
54-
}
55-
5637
@Test
5738
public void testDiffMyersExample1Forward() throws DiffException {
5839
List<String> original = Arrays.asList("A", "B", "C", "A", "B", "B", "A");

0 commit comments

Comments
 (0)