diff options
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java | 13 | ||||
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java | 12 |
2 files changed, 25 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java index 574f85c91a..beda2a7b97 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java @@ -383,6 +383,19 @@ public class RevCommitParseTest extends RepositoryTestCase { assertEquals(src.getMessage(), p.getFullMessage()); } + @Test + public void testParse_GitStyleMessageWithCRLF() throws Exception { + final String shortMsgIn = "This fixes a\r\nbug.\r\n\r\n"; + final String shortMsg = "This fixes a bug."; + final String body = "We do it with magic and pixie dust\r\nand stuff.\r\n" + + "\r\n\r\n" + + "Signed-off-by: A U. Thor <author@example.com>\r\n"; + final String fullMsg = shortMsgIn + "\r\n" + "\r\n" + body; + final RevCommit c = create(fullMsg); + assertEquals(fullMsg, c.getFullMessage()); + assertEquals(shortMsg, c.getShortMessage()); + } + private static ObjectId id(final String str) { return ObjectId.fromString(str); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java index d7b92ade9d..86fed22afe 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/StringUtilsTest.java @@ -91,4 +91,16 @@ public class StringUtilsTest { assertTrue(StringUtils.equalsIgnoreCase("A", "a")); assertTrue(StringUtils.equalsIgnoreCase("a", "A")); } + + @Test + public void testReplaceLineBreaks() { + assertEquals("a b c ", + StringUtils.replaceLineBreaksWithSpace("a b\nc\r")); + assertEquals("a b c ", + StringUtils.replaceLineBreaksWithSpace("a b\nc\n")); + assertEquals("a b c ", + StringUtils.replaceLineBreaksWithSpace("a b\nc\r\n")); + assertEquals("a b c d", + StringUtils.replaceLineBreaksWithSpace("a\r\nb\nc d")); + } } |