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

Side by Side Diff: third_party/WebKit/Source/wtf/text/TextCodecICUTest.cpp

Issue 2771783003: Move wtf_unittests to platform/wtf/. (Closed)
Patch Set: Rebase. Created 3 years, 8 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "wtf/text/TextCodecICU.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "wtf/Vector.h"
9 #include "wtf/text/CharacterNames.h"
10
11 namespace WTF {
12
13 TEST(TextCodecICUTest, IgnorableCodePoint) {
14 TextEncoding iso2022jp("iso-2022-jp");
15 std::unique_ptr<TextCodec> codec = TextCodecICU::create(iso2022jp, nullptr);
16 Vector<UChar> source;
17 source.push_back('a');
18 source.push_back(zeroWidthJoinerCharacter);
19 CString encoded =
20 codec->encode(source.data(), source.size(), EntitiesForUnencodables);
21 EXPECT_STREQ("a&#8205;", encoded.data());
22 }
23
24 TEST(TextCodecICUTest, UTF32AndQuestionMarks) {
25 Vector<String> aliases;
26 Vector<CString> results;
27
28 const UChar poo[] = {0xd83d, 0xdca9}; // U+1F4A9 PILE OF POO
29
30 aliases.push_back("UTF-32");
31 results.push_back("\xFF\xFE\x00\x00\xA9\xF4\x01\x00");
32
33 aliases.push_back("UTF-32LE");
34 results.push_back("\xA9\xF4\x01\x00");
35
36 aliases.push_back("UTF-32BE");
37 results.push_back("\x00\x01\xF4\xA9");
38
39 ASSERT_EQ(aliases.size(), results.size());
40 for (unsigned i = 0; i < aliases.size(); ++i) {
41 const String& alias = aliases[i];
42 const CString& expected = results[i];
43
44 TextEncoding encoding(alias);
45 std::unique_ptr<TextCodec> codec = TextCodecICU::create(encoding, nullptr);
46 {
47 const UChar* data = nullptr;
48 CString encoded = codec->encode(data, 0, QuestionMarksForUnencodables);
49 EXPECT_STREQ("", encoded.data());
50 }
51 {
52 CString encoded = codec->encode(poo, WTF_ARRAY_LENGTH(poo),
53 QuestionMarksForUnencodables);
54 EXPECT_STREQ(expected.data(), encoded.data());
55 }
56 }
57 }
58 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringViewTest.cpp ('k') | third_party/WebKit/Source/wtf/text/TextCodecLatin1Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698