summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-11-26 10:38:53 +0000
committerAlexander Kornienko <alexfh@google.com>2013-11-26 10:38:53 +0000
commit71d95d6e51641e8475cf4d1664582c1ca5537924 (patch)
tree0d4146d995b51c17822aedd0d6ed4fa8cbe11aad /clang/unittests/Format/FormatTest.cpp
parentb697b538dc07c72c729d1afd1603aa3708475b3b (diff)
downloadbcm5719-llvm-71d95d6e51641e8475cf4d1664582c1ca5537924.tar.gz
bcm5719-llvm-71d95d6e51641e8475cf4d1664582c1ca5537924.zip
Fix crash in getStringSplit.
Summary: getStringSplit used to crash, when trying to split a long string literal containing both printable and unprintable multi-byte UTF-8 characters. Reviewers: djasper, klimek Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2268 llvm-svn: 195728
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index fc0e935037b..a7dce3b86f5 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -6991,6 +6991,16 @@ TEST_F(FormatTest, CountsUTF8CharactersProperly) {
}
TEST_F(FormatTest, SplitsUTF8Strings) {
+ // Non-printable characters' width is currently considered to be the length in
+ // bytes in UTF8. The characters can be displayed in very different manner
+ // (zero-width, single width with a substitution glyph, expanded to their code
+ // (e.g. "<8d>"), so there's no single correct way to handle them.
+ EXPECT_EQ("\"aaaaÄ\"\n"
+ "\"\";",
+ format("\"aaaač\";", getLLVMStyleWithColumns(10)));
+ EXPECT_EQ("\"aaaaaaaÄ\"\n"
+ "\"\";",
+ format("\"aaaaaaač\";", getLLVMStyleWithColumns(10)));
EXPECT_EQ(
"\"Однажды, в \"\n"
"\"студёную \"\n"
@@ -7024,6 +7034,8 @@ TEST_F(FormatTest, HandlesDoubleWidthCharsInMultiLineStrings) {
}
TEST_F(FormatTest, SplitsUTF8LineComments) {
+ EXPECT_EQ("// aaaač",
+ format("// aaaač", getLLVMStyleWithColumns(10)));
EXPECT_EQ("// Я из лесу\n"
"// вышел; был\n"
"// сильный\n"
OpenPOWER on IntegriCloud