From 1e5b60fa2e46d67e29ba5e23c6891f70995890c1 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sun, 5 Apr 2015 16:05:11 +0300 Subject: [PATCH] [git] IDEA-128280 : test against 0001 and 0003 chars in the log output --- .../git4idea/history/GitLogParserTest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/plugins/git4idea/tests/git4idea/history/GitLogParserTest.java b/plugins/git4idea/tests/git4idea/history/GitLogParserTest.java index 83ac37f47163..d7ddaeb15d0f 100644 --- a/plugins/git4idea/tests/git4idea/history/GitLogParserTest.java +++ b/plugins/git4idea/tests/git4idea/history/GitLogParserTest.java @@ -147,6 +147,36 @@ public class GitLogParserTest extends GitPlatformTest { doTestOneRecord(STATUS); } + public void test_char_0001_in_commit_message() throws VcsException { + doTestCustomCommitMessage("Commit \u0001subject", "Commit subject"); + } + + public void test_char_0003_in_commit_message() throws VcsException { + doTestCustomCommitMessage("Commit \u0003subject", "Commit \u0003subject"); + } + + // this is not fixed, keeping the test for the record and possible future fixx + @SuppressWarnings("unused") + public void _test_both_chars_0001_and_0003_in_commit_message() throws VcsException { + doTestCustomCommitMessage("Subject \u0001of the \u0003# weirdmessage", "Subject of the \u0003# weird message"); + } + + public void test_char_0001_twice_in_commit_message() throws VcsException { + doTestCustomCommitMessage("Subject \u0001of the \u0001# weird message", "Subject of the # weird message"); + } + + private void doTestCustomCommitMessage(@NotNull String subject, @NotNull String expectedSubject) { + Map data = ContainerUtil.newHashMap(myRecord.myData); + data.put(GitTestLogRecordInfo.SUBJECT, subject); + myRecord = new GitTestLogRecord(data); + + myParser = new GitLogParser(myProject, STATUS, GIT_LOG_OPTIONS); + String s = myRecord.prepareOutputLine(NONE); + List records = myParser.parse(s); + assertEquals("Incorrect amount of actual records: " + StringUtil.join(records, "\n"), 1, records.size()); + assertEquals(records.get(0).getSubject(), expectedSubject); + } + private void doTestOneRecord(NameStatus option) throws VcsException { String s = myRecord.prepareOutputLine(option); GitLogRecord record = myParser.parseOneRecord(s);