mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
Tests - fixed failing tests
This commit is contained in:
parent
c004a11c6b
commit
a4609c50f2
13 changed files with 166 additions and 367 deletions
|
@ -208,9 +208,12 @@ class StringDiffUtils {
|
|||
start += l.text.length();
|
||||
}
|
||||
|
||||
// strip off the trailing newline that we added above
|
||||
if (result.isEmpty()) {
|
||||
result.add(new Line("", 0));
|
||||
}
|
||||
|
||||
Line last = result.peekLast();
|
||||
last.markAsLast();
|
||||
last.markAsLast(); // this will signal to remove the trailing newline for the last line
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -159,6 +159,39 @@ public class StringDiffTest {
|
|||
assertEquals(v2, restoredV2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLineDiffs_Empty() {
|
||||
|
||||
String v1 = "";
|
||||
String v2 = "";
|
||||
|
||||
StringDiff[] diffs = StringDiffUtils.getLineDiffs(v1, v2, 0);
|
||||
String restoredV2 = StringDiffUtils.applyDiffs(v1, Arrays.asList(diffs));
|
||||
assertEquals(v2, restoredV2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLineDiffs_EmptyInitial() {
|
||||
|
||||
String v1 = "";
|
||||
String v2 = "This is not empty";
|
||||
|
||||
StringDiff[] diffs = StringDiffUtils.getLineDiffs(v1, v2, 0);
|
||||
String restoredV2 = StringDiffUtils.applyDiffs(v1, Arrays.asList(diffs));
|
||||
assertEquals(v2, restoredV2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLineDiffs_EmptyReplacement() {
|
||||
|
||||
String v1 = "This is not empty";
|
||||
String v2 = "";
|
||||
|
||||
StringDiff[] diffs = StringDiffUtils.getLineDiffs(v1, v2, 0);
|
||||
String restoredV2 = StringDiffUtils.applyDiffs(v1, Arrays.asList(diffs));
|
||||
assertEquals(v2, restoredV2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplace() {
|
||||
String[] a1 = new String[] { "In", "the", "beginning" };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue