|
|
@ -46,6 +46,7 @@ package org.eclipse.jgit.diff; |
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
|
|
|
|
|
import static org.junit.Assert.assertNull; |
|
|
|
import static org.junit.Assert.assertTrue; |
|
|
|
import static org.junit.Assert.assertTrue; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
@ -189,6 +190,46 @@ public class RawTextTest { |
|
|
|
assertEquals(new Edit(0, 1, 0, 2), e); |
|
|
|
assertEquals(new Edit(0, 1, 0, 2), e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void testLineDelimiter() throws Exception { |
|
|
|
|
|
|
|
RawText rt = new RawText(Constants.encodeASCII("foo\n")); |
|
|
|
|
|
|
|
assertEquals("\n", rt.getLineDelimiter()); |
|
|
|
|
|
|
|
assertFalse(rt.isMissingNewlineAtEnd()); |
|
|
|
|
|
|
|
rt = new RawText(Constants.encodeASCII("foo\r\n")); |
|
|
|
|
|
|
|
assertEquals("\r\n", rt.getLineDelimiter()); |
|
|
|
|
|
|
|
assertFalse(rt.isMissingNewlineAtEnd()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rt = new RawText(Constants.encodeASCII("foo\nbar")); |
|
|
|
|
|
|
|
assertEquals("\n", rt.getLineDelimiter()); |
|
|
|
|
|
|
|
assertTrue(rt.isMissingNewlineAtEnd()); |
|
|
|
|
|
|
|
rt = new RawText(Constants.encodeASCII("foo\r\nbar")); |
|
|
|
|
|
|
|
assertEquals("\r\n", rt.getLineDelimiter()); |
|
|
|
|
|
|
|
assertTrue(rt.isMissingNewlineAtEnd()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rt = new RawText(Constants.encodeASCII("foo\nbar\r\n")); |
|
|
|
|
|
|
|
assertEquals("\n", rt.getLineDelimiter()); |
|
|
|
|
|
|
|
assertFalse(rt.isMissingNewlineAtEnd()); |
|
|
|
|
|
|
|
rt = new RawText(Constants.encodeASCII("foo\r\nbar\n")); |
|
|
|
|
|
|
|
assertEquals("\r\n", rt.getLineDelimiter()); |
|
|
|
|
|
|
|
assertFalse(rt.isMissingNewlineAtEnd()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rt = new RawText(Constants.encodeASCII("foo")); |
|
|
|
|
|
|
|
assertNull(rt.getLineDelimiter()); |
|
|
|
|
|
|
|
assertTrue(rt.isMissingNewlineAtEnd()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rt = new RawText(Constants.encodeASCII("")); |
|
|
|
|
|
|
|
assertNull(rt.getLineDelimiter()); |
|
|
|
|
|
|
|
assertTrue(rt.isMissingNewlineAtEnd()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rt = new RawText(Constants.encodeASCII("\n")); |
|
|
|
|
|
|
|
assertEquals("\n", rt.getLineDelimiter()); |
|
|
|
|
|
|
|
assertFalse(rt.isMissingNewlineAtEnd()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rt = new RawText(Constants.encodeASCII("\r\n")); |
|
|
|
|
|
|
|
assertEquals("\r\n", rt.getLineDelimiter()); |
|
|
|
|
|
|
|
assertFalse(rt.isMissingNewlineAtEnd()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static RawText t(String text) { |
|
|
|
private static RawText t(String text) { |
|
|
|
StringBuilder r = new StringBuilder(); |
|
|
|
StringBuilder r = new StringBuilder(); |
|
|
|
for (int i = 0; i < text.length(); i++) { |
|
|
|
for (int i = 0; i < text.length(); i++) { |
|
|
|