diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-11-26 10:38:53 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-11-26 10:38:53 +0000 |
commit | 71d95d6e51641e8475cf4d1664582c1ca5537924 (patch) | |
tree | 0d4146d995b51c17822aedd0d6ed4fa8cbe11aad /clang/unittests/Format/FormatTest.cpp | |
parent | b697b538dc07c72c729d1afd1603aa3708475b3b (diff) | |
download | bcm5719-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.cpp | 12 |
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" |