Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Brandys2009-02-25 11:52:28 +0000
committerSzymon Brandys2009-02-25 11:52:28 +0000
commit94551e164e80b0b5dab6d6d93ab8755c9e0dcc0b (patch)
treee2f261fd8485171de83deda6a361286e5856ce9c /tests/org.eclipse.compare.tests/src/org/eclipse
parentfda4d71493b877bc954eba464cb3ba837cdf38ae (diff)
downloadeclipse.platform.team-94551e164e80b0b5dab6d6d93ab8755c9e0dcc0b.tar.gz
eclipse.platform.team-94551e164e80b0b5dab6d6d93ab8755c9e0dcc0b.tar.xz
eclipse.platform.team-94551e164e80b0b5dab6d6d93ab8755c9e0dcc0b.zip
Bug 265824 - [Apply Patch] API to get lines from IHunks
Diffstat (limited to 'tests/org.eclipse.compare.tests/src/org/eclipse')
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java
index 177f82030..a69656f33 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java
@@ -226,6 +226,9 @@ public class PatchBuilderTest extends TestCase {
" [b]", "-[c]", " [d]", " [e]", " [f]" };
addLineDelimiters(lines);
Hunk hunk = (Hunk) PatchBuilder.createHunk(0, lines);
+ String[] actual = hunk.getUnifiedLines();
+ assertTrue(lines != actual);
+ assertLinesEquals(lines, actual);
assertHunkEquals(hunk, (Hunk) filePatches[0].getHunks()[0]);
}
@@ -241,6 +244,9 @@ public class PatchBuilderTest extends TestCase {
"+[j2]", " [k]", " [l]", " [m]" };
addLineDelimiters(lines);
Hunk hunk = (Hunk) PatchBuilder.createHunk(0, lines);
+ String[] actual = hunk.getUnifiedLines();
+ assertTrue(lines != actual);
+ assertLinesEquals(lines, actual);
assertHunkEquals(hunk, (Hunk) filePatches[0].getHunks()[0]);
}
@@ -254,6 +260,9 @@ public class PatchBuilderTest extends TestCase {
String[] lines = new String[] { "+[aa]", "+[bb]", "+[cc]" };
addLineDelimiters(lines);
Hunk hunk = (Hunk) PatchBuilder.createHunk(0, lines);
+ String[] actual = hunk.getUnifiedLines();
+ assertTrue(lines != actual);
+ assertLinesEquals(lines, actual);
assertHunkEquals(hunk, (Hunk) filePatches[0].getHunks()[0]);
}
@@ -267,6 +276,9 @@ public class PatchBuilderTest extends TestCase {
String[] lines = new String[] { "-[aa]", "-[bb]", "-[cc]", "-[dd]" };
addLineDelimiters(lines);
Hunk hunk = (Hunk) PatchBuilder.createHunk(0, lines);
+ String[] actual = hunk.getUnifiedLines();
+ assertTrue(lines != actual);
+ assertLinesEquals(lines, actual);
assertHunkEquals(hunk, (Hunk) filePatches[0].getHunks()[0]);
}
@@ -287,6 +299,13 @@ public class PatchBuilderTest extends TestCase {
assertEquals(h1.getHunkType(true), h2.getHunkType(true));
}
+ private void assertLinesEquals(String[] expected, String[] actual) {
+ assertEquals(expected.length, actual.length);
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals(expected[i], actual[i]);
+ }
+ }
+
private void addLineDelimiters(String[] lines) {
for (int i = 0; i < lines.length; i++) {
lines[i] = lines[i] + "\r\n";

Back to the top