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

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

Issue 2470043004: Fix vector resize logic when encoding non-BMP chars to latin1 as ?s (Closed)
Patch Set: rebased 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
« no previous file with comments | « third_party/WebKit/Source/wtf/text/TextCodecLatin1.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/TextCodecLatin1Test.cpp
diff --git a/third_party/WebKit/Source/wtf/text/TextCodecLatin1Test.cpp b/third_party/WebKit/Source/wtf/text/TextCodecLatin1Test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..71fb8d15b481e7334abd122a90d1dfbb237591df
--- /dev/null
+++ b/third_party/WebKit/Source/wtf/text/TextCodecLatin1Test.cpp
@@ -0,0 +1,39 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "wtf/text/TextCodecLatin1.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/TextCodec.h"
+#include "wtf/text/TextEncoding.h"
+#include "wtf/text/TextEncodingRegistry.h"
+#include <memory>
+
+TEST(TextCodecLatin1Test, QuestionMarksAndSurrogates) {
+ WTF::TextEncoding encoding("windows-1252");
+ std::unique_ptr<WTF::TextCodec> codec(newTextCodec(encoding));
+
+ {
+ const LChar testCase[] = {0xd1, 0x16, 0x86};
+ size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
+ CString result = codec->encode(testCase, testCaseSize,
+ WTF::QuestionMarksForUnencodables);
+ EXPECT_STREQ("\xd1\x16?", result.data());
+ }
+ {
+ const UChar testCase[] = {0xd9f0, 0xdcd9};
+ size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
+ CString result = codec->encode(testCase, testCaseSize,
+ WTF::QuestionMarksForUnencodables);
+ EXPECT_STREQ("?", result.data());
+ }
+ {
+ const UChar testCase[] = {0xd9f0, 0xdcd9, 0xd9f0, 0xdcd9};
+ size_t testCaseSize = WTF_ARRAY_LENGTH(testCase);
+ CString result = codec->encode(testCase, testCaseSize,
+ WTF::QuestionMarksForUnencodables);
+ EXPECT_STREQ("??", result.data());
+ }
+}
« no previous file with comments | « third_party/WebKit/Source/wtf/text/TextCodecLatin1.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698