]> granicus.if.org Git - clang/commitdiff
Adds a test for the command line parser when a quoted string is not closed by a quote.
authorManuel Klimek <klimek@google.com>
Mon, 2 May 2011 18:27:26 +0000 (18:27 +0000)
committerManuel Klimek <klimek@google.com>
Mon, 2 May 2011 18:27:26 +0000 (18:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130704 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Tooling/JsonCompileCommandLineDatabaseTest.cpp

index d875293e5d857646a988d5892997c7e2ed7fdaa3..2a911d10635b2bd96ebbe5b0ecd632f9b476bcb7 100644 (file)
@@ -92,6 +92,20 @@ TEST(UnescapeJsonCommandLine, ParsesStringsWithoutSpacesIntoSingleArgument) {
   EXPECT_EQ("abcdefg", MixedNoSpaces[0]);
 }
 
+TEST(UnescapeJsonCommandLine, ParsesQuotedStringWithoutClosingQuote) {
+  std::vector<std::string> Unclosed = UnescapeJsonCommandLine("\"abc");
+  ASSERT_EQ(1ul, Unclosed.size());
+  EXPECT_EQ("abc", Unclosed[0]);
+
+  std::vector<std::string> EndsInBackslash = UnescapeJsonCommandLine("\"a\\");
+  ASSERT_EQ(1ul, EndsInBackslash.size());
+  EXPECT_EQ("a", EndsInBackslash[0]);
+
+  std::vector<std::string> Empty = UnescapeJsonCommandLine("\"");
+  ASSERT_EQ(1ul, Empty.size());
+  EXPECT_EQ("", Empty[0]);
+}
+
 TEST(JsonCompileCommandLineParser, FailsOnEmptyString) {
   JsonCompileCommandLineParser Parser("", NULL);
   EXPECT_FALSE(Parser.Parse()) << Parser.GetErrorMessage();