This commit is contained in:
wumpz
2017-04-27 00:33:45 +02:00
parent 134f80f3e3
commit d04f43ef02
5 changed files with 6 additions and 81 deletions

View File

@@ -44,7 +44,7 @@ public class JGitDiff<T> implements DiffAlgorithm<T> {
diffList.addAll(new HistogramDiff().diff(new DataListComparator<>(), new DataList<>(original), new DataList<>(revised)));
List<Change> patch = new ArrayList<>();
for (Edit edit : diffList) {
DeltaType type = DeltaType.EQUAL;
DeltaType type;
switch (edit.getType()) {
case DELETE:
type = DeltaType.DELETE;
@@ -55,6 +55,8 @@ public class JGitDiff<T> implements DiffAlgorithm<T> {
case REPLACE:
type = DeltaType.CHANGE;
break;
default:
type = DeltaType.EQUAL;
}
patch.add(new Change(type,edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB()));
}

View File

@@ -49,6 +49,9 @@ import java.util.regex.Pattern;
*/
public class DiffRowGenerator {
public static final BiPredicate<String,String> IGNORE_WHITESPACE_EQUALIZER = (original, revised)
-> original.trim().replaceAll("\\s+", " ").equals(revised.trim().replaceAll("\\s+", " "));
public static final BiPredicate<String,String> DEFAULT_EQUALIZER = Object::equals;
private static final Pattern SPLIT_PATTERN = Pattern.compile("\\s+|[,.\\[\\](){}/\\\\*+\\-#]");
private final boolean showInlineDiffs;
private final boolean ignoreWhiteSpaces;
@@ -171,10 +174,6 @@ public class DiffRowGenerator {
public static Builder create() {
return new Builder();
}
public static final BiPredicate<String,String> IGNORE_WHITESPACE_EQUALIZER = (original, revised)
-> original.trim().replaceAll("\\s+", " ").equals(revised.trim().replaceAll("\\s+", " "));
public static final BiPredicate<String,String> DEFAULT_EQUALIZER = Object::equals;
private DiffRowGenerator(Builder builder) {
showInlineDiffs = builder.showInlineDiffs;

View File

@@ -15,20 +15,11 @@
*/
package com.github.difflib.algorithm.jgit;
import com.github.difflib.algorithm.jgit.JGitDiff;
import static com.github.difflib.DiffUtilsTest.readStringListFromInputStream;
import com.github.difflib.TestConstants;
import com.github.difflib.algorithm.DiffException;
import com.github.difflib.patch.Patch;
import com.github.difflib.patch.PatchFailedException;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.zip.ZipFile;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -37,29 +28,7 @@ import static org.junit.Assert.*;
* @author toben
*/
public class JGitDiffTest {
public JGitDiffTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of diff method, of class JGitDiff.
*/
@Test
public void testDiff() throws DiffException, PatchFailedException {
List<String> orgList = Arrays.asList("A","B","C","A","B","B","A");

View File

@@ -15,20 +15,14 @@
*/
package com.github.difflib.algorithm.jgit;
import com.github.difflib.algorithm.jgit.JGitDiff;
import static com.github.difflib.DiffUtilsTest.readStringListFromInputStream;
import com.github.difflib.TestConstants;
import com.github.difflib.algorithm.DiffException;
import com.github.difflib.patch.Patch;
import com.github.difflib.patch.PatchFailedException;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.zip.ZipFile;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -38,26 +32,6 @@ import static org.junit.Assert.*;
*/
public class LRJGitDiffTest {
public LRJGitDiffTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
@Test
public void testPossibleDiffHangOnLargeDatasetDnaumenkoIssue26() throws IOException, DiffException, PatchFailedException {
ZipFile zip = new ZipFile(TestConstants.MOCK_FOLDER + "/large_dataset1.zip");

View File

@@ -34,25 +34,6 @@ import static org.junit.Assert.*;
*/
public class MyersDiffTest {
public MyersDiffTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
@Test
public void testDiffMyersExample1Forward() throws DiffException {
List<String> original = Arrays.asList("A", "B", "C", "A", "B", "B", "A");