| OLD | NEW |
| (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/TextCodecUserDefined.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 #include "wtf/text/CString.h" | |
| 9 #include "wtf/text/TextCodec.h" | |
| 10 #include "wtf/text/TextEncoding.h" | |
| 11 #include "wtf/text/TextEncodingRegistry.h" | |
| 12 #include <memory> | |
| 13 | |
| 14 TEST(TextCodecUserDefinedTest, QuestionMarksAndSurrogates) { | |
| 15 WTF::TextEncoding encoding("x-user-defined"); | |
| 16 std::unique_ptr<WTF::TextCodec> codec(newTextCodec(encoding)); | |
| 17 | |
| 18 { | |
| 19 const LChar testCase[] = {0xd1, 0x16, 0x86}; | |
| 20 size_t testCaseSize = WTF_ARRAY_LENGTH(testCase); | |
| 21 CString result = codec->encode(testCase, testCaseSize, | |
| 22 WTF::QuestionMarksForUnencodables); | |
| 23 EXPECT_STREQ("?\x16?", result.data()); | |
| 24 } | |
| 25 { | |
| 26 const UChar testCase[] = {0xd9f0, 0xdcd9}; | |
| 27 size_t testCaseSize = WTF_ARRAY_LENGTH(testCase); | |
| 28 CString result = codec->encode(testCase, testCaseSize, | |
| 29 WTF::QuestionMarksForUnencodables); | |
| 30 EXPECT_STREQ("?", result.data()); | |
| 31 } | |
| 32 { | |
| 33 const UChar testCase[] = {0xd9f0, 0xdcd9, 0xd9f0, 0xdcd9}; | |
| 34 size_t testCaseSize = WTF_ARRAY_LENGTH(testCase); | |
| 35 CString result = codec->encode(testCase, testCaseSize, | |
| 36 WTF::QuestionMarksForUnencodables); | |
| 37 EXPECT_STREQ("??", result.data()); | |
| 38 } | |
| 39 { | |
| 40 const UChar testCase[] = {0x0041, 0xd9f0, 0xdcd9, 0xf7c1, 0xd9f0, 0xdcd9}; | |
| 41 size_t testCaseSize = WTF_ARRAY_LENGTH(testCase); | |
| 42 CString result = codec->encode(testCase, testCaseSize, | |
| 43 WTF::QuestionMarksForUnencodables); | |
| 44 EXPECT_STREQ("A?\xC1?", result.data()); | |
| 45 } | |
| 46 } | |
| OLD | NEW |