Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Unified Diff: third_party/WebKit/Source/wtf/text/TextCodecICUTest.cpp

Issue 2478653002: Don't initialize ICU replacement character for UTF-32 encodings (Closed)
Patch Set: Don't use zero-length array initializer, to keep MSVC happy Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/text/TextCodecICUTest.cpp
diff --git a/third_party/WebKit/Source/wtf/text/TextCodecICUTest.cpp b/third_party/WebKit/Source/wtf/text/TextCodecICUTest.cpp
index be01823a2b42b50ee3bd2e2dfc66523159f743e5..bb3146f4592c9ec1ac40a5fa2553441a8107202d 100644
--- a/third_party/WebKit/Source/wtf/text/TextCodecICUTest.cpp
+++ b/third_party/WebKit/Source/wtf/text/TextCodecICUTest.cpp
@@ -5,6 +5,7 @@
#include "wtf/text/TextCodecICU.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "wtf/Vector.h"
#include "wtf/text/CharacterNames.h"
namespace WTF {
@@ -19,4 +20,39 @@ TEST(TextCodecICUTest, IgnorableCodePoint) {
codec->encode(source.data(), source.size(), EntitiesForUnencodables);
EXPECT_STREQ("a‍", encoded.data());
}
+
+TEST(TextCodecICUTest, UTF32AndQuestionMarks) {
+ Vector<String> aliases;
+ Vector<CString> results;
+
+ const UChar poo[] = {0xd83d, 0xdca9}; // U+1F4A9 PILE OF POO
+
+ aliases.append("UTF-32");
+ results.append("\xFF\xFE\x00\x00\xA9\xF4\x01\x00");
+
+ aliases.append("UTF-32LE");
+ results.append("\xA9\xF4\x01\x00");
+
+ aliases.append("UTF-32BE");
+ results.append("\x00\x01\xF4\xA9");
+
+ ASSERT_EQ(aliases.size(), results.size());
+ for (unsigned i = 0; i < aliases.size(); ++i) {
+ const String& alias = aliases[i];
+ const CString& expected = results[i];
+
+ TextEncoding encoding(alias);
+ std::unique_ptr<TextCodec> codec = TextCodecICU::create(encoding, nullptr);
+ {
+ const UChar* data = nullptr;
+ CString encoded = codec->encode(data, 0, QuestionMarksForUnencodables);
+ EXPECT_STREQ("", encoded.data());
+ }
+ {
+ CString encoded = codec->encode(poo, WTF_ARRAY_LENGTH(poo),
+ QuestionMarksForUnencodables);
+ EXPECT_STREQ(expected.data(), encoded.data());
+ }
+ }
+}
}
« no previous file with comments | « third_party/WebKit/Source/wtf/text/TextCodecICU.cpp ('k') | third_party/WebKit/Source/wtf/text/TextEncoding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698