OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "wtf/text/TextCodecReplacement.h" | 7 #include "wtf/text/TextCodecReplacement.h" |
8 | 8 |
9 #include "wtf/OwnPtr.h" | 9 #include "wtf/OwnPtr.h" |
10 #include "wtf/text/CString.h" | 10 #include "wtf/text/CString.h" |
11 #include "wtf/text/TextCodec.h" | 11 #include "wtf/text/TextCodec.h" |
12 #include "wtf/text/TextEncoding.h" | 12 #include "wtf/text/TextEncoding.h" |
13 #include "wtf/text/TextEncodingRegistry.h" | 13 #include "wtf/text/TextEncodingRegistry.h" |
14 #include "wtf/text/WTFString.h" | 14 #include "wtf/text/WTFString.h" |
15 #include <gtest/gtest.h> | 15 #include <gtest/gtest.h> |
16 | 16 |
17 namespace WTF { | 17 namespace WTF { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // Just one example, others are listed in the codec implementation. | 21 // Just one example, others are listed in the codec implementation. |
22 const char* replacementAlias = "iso-2022-kr"; | 22 const char* replacementAlias = "iso-2022-kr"; |
23 | 23 |
24 TEST(TextCodecReplacement, Aliases) | 24 TEST(TextCodecReplacement, Aliases) |
25 { | 25 { |
26 // FIXME: The 'replacement' label itself should not be referenceable by | 26 // "replacement" is not a valid alias for itself |
27 // resources or script - it's a specification convenience - but much of | 27 EXPECT_FALSE(TextEncoding("replacement").isValid()); |
28 // the wtf/text API asserts that an encoding name is a label for itself. | 28 EXPECT_FALSE(TextEncoding("rEpLaCeMeNt").isValid()); |
29 // crbug.com/277037 | |
30 | 29 |
31 EXPECT_TRUE(TextEncoding(replacementAlias).isValid()); | 30 EXPECT_TRUE(TextEncoding(replacementAlias).isValid()); |
32 EXPECT_STREQ("replacement", TextEncoding(replacementAlias).name()); | 31 EXPECT_STREQ("replacement", TextEncoding(replacementAlias).name()); |
33 } | 32 } |
34 | 33 |
35 TEST(TextCodecReplacement, DecodesToFFFD) | 34 TEST(TextCodecReplacement, DecodesToFFFD) |
36 { | 35 { |
37 TextEncoding encoding(replacementAlias); | 36 TextEncoding encoding(replacementAlias); |
38 OwnPtr<TextCodec> codec(newTextCodec(encoding)); | 37 OwnPtr<TextCodec> codec(newTextCodec(encoding)); |
39 | 38 |
(...skipping 16 matching lines...) Expand all Loading... |
56 const UChar testCase[] = { 0x6F22, 0x5B57 }; | 55 const UChar testCase[] = { 0x6F22, 0x5B57 }; |
57 size_t testCaseSize = WTF_ARRAY_LENGTH(testCase); | 56 size_t testCaseSize = WTF_ARRAY_LENGTH(testCase); |
58 CString result = codec->encode(testCase, testCaseSize, QuestionMarksForUnenc
odables); | 57 CString result = codec->encode(testCase, testCaseSize, QuestionMarksForUnenc
odables); |
59 | 58 |
60 EXPECT_STREQ("\xE6\xBC\xA2\xE5\xAD\x97", result.data()); | 59 EXPECT_STREQ("\xE6\xBC\xA2\xE5\xAD\x97", result.data()); |
61 } | 60 } |
62 | 61 |
63 } // namespace | 62 } // namespace |
64 | 63 |
65 } // namespace WTF | 64 } // namespace WTF |
OLD | NEW |