use of org.eclipse.jgit.diff.Edit in project gerrit by GerritCodeReview.
the class MultilineContentWithEOLTest method replaceWithSingleLineNoEOLAtStart.
@Test
public void replaceWithSingleLineNoEOLAtStart() throws Exception {
FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 1, 0, 1, 2, "Abc");
assertThat(fixResult).text().isEqualTo("Abcrst line\nSecond line\nThird line\n");
assertThat(fixResult).edits().hasSize(1);
Edit edit = fixResult.edits.get(0);
assertThat(edit).isReplace(0, 1, 0, 1);
assertThat(edit).internalEdits().onlyElement().isReplace(0, 2, 0, 3);
}
use of org.eclipse.jgit.diff.Edit in project gerrit by GerritCodeReview.
the class MultilineContentWithEOLTest method replaceWithSingleLineNoEOLInTheMiddle.
@Test
public void replaceWithSingleLineNoEOLInTheMiddle() throws Exception {
FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 2, 3, 2, 5, "Abc");
assertThat(fixResult).text().isEqualTo("First line\nSecAbcd line\nThird line\n");
assertThat(fixResult).edits().hasSize(1);
Edit edit = fixResult.edits.get(0);
assertThat(edit).isReplace(1, 1, 1, 1);
assertThat(edit).internalEdits().onlyElement().isReplace(3, 2, 3, 3);
}
use of org.eclipse.jgit.diff.Edit in project gerrit by GerritCodeReview.
the class MultilineContentWithEOLTest method deleteInTheMiddle.
@Test
public void deleteInTheMiddle() throws Exception {
FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 1, 5, 3, 1, "");
assertThat(fixResult).text().isEqualTo("Firsthird line\n");
assertThat(fixResult).edits().hasSize(1);
Edit edit = fixResult.edits.get(0);
assertThat(edit).isReplace(0, 3, 0, 1);
assertThat(edit).internalEdits().onlyElement().isDelete(5, 19, 5);
}
use of org.eclipse.jgit.diff.Edit in project gerrit by GerritCodeReview.
the class MultilineContentWithEOLTest method replaceMultilineLineNoEOLAtStart.
@Test
public void replaceMultilineLineNoEOLAtStart() throws Exception {
FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 1, 0, 1, 2, "Abc\nDefgh");
assertThat(fixResult).text().isEqualTo("Abc\nDefghrst line\nSecond line\nThird line\n");
assertThat(fixResult).edits().hasSize(1);
Edit edit = fixResult.edits.get(0);
assertThat(edit).isReplace(0, 1, 0, 2);
assertThat(edit).internalEdits().onlyElement().isReplace(0, 2, 0, 9);
}
use of org.eclipse.jgit.diff.Edit in project gerrit by GerritCodeReview.
the class MultilineContentWithEOLTest method insertMultilineLineWithEOLAtEnd.
@Test
public void insertMultilineLineWithEOLAtEnd() throws Exception {
FixResult fixResult = FixCalculatorVariousTest.calculateFixSingleReplacement("First line\nSecond line\nThird line\n", 4, 0, 4, 0, "Abc\nDefgh\n");
assertThat(fixResult).text().isEqualTo("First line\nSecond line\nThird line\nAbc\nDefgh\n");
assertThat(fixResult).edits().hasSize(1);
Edit edit = fixResult.edits.get(0);
assertThat(edit).isInsert(3, 3, 2);
assertThat(edit).internalEdits().onlyElement().isInsert(0, 0, 10);
}
Aggregations