aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-03-08 18:59:48 +0000
committerManuel Klimek <klimek@google.com>2013-03-08 18:59:48 +0000
commitaa62d0c4fc9449d4c438fe200ef329b067c037c7 (patch)
tree218b4ebaab09258b8490fde8e4cc62f0ae13b860 /unittests/Format/FormatTest.cpp
parentc2ac68e09f4adf0f9fcfe53c1fcc5e87d069806a (diff)
Fixes breaking of string literals.
1. We now ignore all non-default string literals, including raw literals. 2. We do not break inside escape sequences any more. FIXME: We still break in trigraphs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176710 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 1e92592488..0ac3c10dc7 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -3108,5 +3108,44 @@ TEST_F(FormatTest, BreakStringLiterals) {
format("\"split/pathat/slashes\"", getLLVMStyleWithColumns(10)));
}
+TEST_F(FormatTest, DoNotBreakStringLiteralsInEscapeSequence) {
+ EXPECT_EQ("\"\\a\"",
+ format("\"\\a\"", getLLVMStyleWithColumns(3)));
+ EXPECT_EQ("\"\\\"",
+ format("\"\\\"", getLLVMStyleWithColumns(2)));
+ EXPECT_EQ("\"test\"\n"
+ "\"\\n\"",
+ format("\"test\\n\"", getLLVMStyleWithColumns(7)));
+ EXPECT_EQ("\"tes\\\\\"\n"
+ "\"n\"",
+ format("\"tes\\\\n\"", getLLVMStyleWithColumns(7)));
+ EXPECT_EQ("\"\\\\\\\\\"\n"
+ "\"\\n\"",
+ format("\"\\\\\\\\\\n\"", getLLVMStyleWithColumns(7)));
+ EXPECT_EQ("\"\\uff01\"",
+ format("\"\\uff01\"", getLLVMStyleWithColumns(7)));
+ EXPECT_EQ("\"\\uff01\"\n"
+ "\"test\"",
+ format("\"\\uff01test\"", getLLVMStyleWithColumns(8)));
+ EXPECT_EQ("\"\\Uff01ff02\"",
+ format("\"\\Uff01ff02\"", getLLVMStyleWithColumns(11)));
+ EXPECT_EQ("\"\\x000000000001\"\n"
+ "\"next\"",
+ format("\"\\x000000000001next\"", getLLVMStyleWithColumns(16)));
+ EXPECT_EQ("\"\\x000000000001next\"",
+ format("\"\\x000000000001next\"", getLLVMStyleWithColumns(15)));
+ EXPECT_EQ("\"\\x000000000001\"",
+ format("\"\\x000000000001\"", getLLVMStyleWithColumns(7)));
+ EXPECT_EQ("\"test\"\n"
+ "\"\\000000\"\n"
+ "\"000001\"",
+ format("\"test\\000000000001\"", getLLVMStyleWithColumns(9)));
+ EXPECT_EQ("\"test\\000\"\n"
+ "\"000000001\"",
+ format("\"test\\000000000001\"", getLLVMStyleWithColumns(10)));
+ EXPECT_EQ("R\"(\\x\\x00)\"\n",
+ format("R\"(\\x\\x00)\"\n", getLLVMStyleWithColumns(7)));
+}
+
} // end namespace tooling
} // end namespace clang