OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2006-2009 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 "chrome_frame/test/chrome_frame_unittests.h" |
| 6 |
| 7 // Need to include these first since they're included |
| 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" |
| 10 #include "googleurl/src/url_canon.h" |
| 11 |
| 12 // Include the implementation of our stubs into a special namespace so that |
| 13 // we can separate them from Chrome's implementation. |
| 14 namespace icu_stubs { |
| 15 // This struct is only to avoid build problems for the two googleurl stubs |
| 16 // that currently are noops. |
| 17 struct CanonOutputW { }; |
| 18 |
| 19 #include "chrome_frame/icu_stubs.cc" |
| 20 } // namespace icu_stubs |
| 21 |
| 22 // anonymous namespace for test data. |
| 23 namespace { |
| 24 |
| 25 // Test strings borrowed from base/string_util_unittest.cc |
| 26 static const wchar_t* const kConvertRoundtripCases[] = { |
| 27 L"", |
| 28 L"Google Vid¯ôfY »" |
| 29 L"\x7f51\x9875\x0020\x56fe\x7247\x0020\x8d44\x8baf\x66f4\x591a\x0020\x00bb", |
| 30 // " ±³ºÌü¹¿Â ÃÄÌÂ" |
| 31 L"\x03a0\x03b1\x03b3\x03ba\x03cc\x03c3\x03bc\x03b9" |
| 32 L"\x03bf\x03c2\x0020\x0399\x03c3\x03c4\x03cc\x03c2", |
| 33 // ">8A: AB@0=8F =0 @CAA:><" |
| 34 L"\x041f\x043e\x0438\x0441\x043a\x0020\x0441\x0442" |
| 35 L"\x0440\x0430\x043d\x0438\x0446\x0020\x043d\x0430" |
| 36 L"\x0020\x0440\x0443\x0441\x0441\x043a\x043e\x043c", |
| 37 // "È´ÌÁD¾¤Â" |
| 38 L"\xc804\xccb4\xc11c\xbe44\xc2a4", |
| 39 |
| 40 // Test characters that take more than 16 bits. This will depend on whether |
| 41 // wchar_t is 16 or 32 bits. |
| 42 #if defined(WCHAR_T_IS_UTF16) |
| 43 L"\xd800\xdf00", |
| 44 // ????? (Mathematical Alphanumeric Symbols (U+011d40 - U+011d44 : A,B,C,D,
E) |
| 45 L"\xd807\xdd40\xd807\xdd41\xd807\xdd42\xd807\xdd43\xd807\xdd44", |
| 46 #elif defined(WCHAR_T_IS_UTF32) |
| 47 L"\x10300", |
| 48 // ????? (Mathematical Alphanumeric Symbols (U+011d40 - U+011d44 : A,B,C,D,
E) |
| 49 L"\x11d40\x11d41\x11d42\x11d43\x11d44", |
| 50 #endif |
| 51 }; |
| 52 |
| 53 } // namespace |
| 54 |
| 55 TEST(IcuStubsTests, UTF8AndWideStubTest) { |
| 56 // Test code borrowed from ConvertUTF8AndWide in base/string_util_unittest.cc. |
| 57 |
| 58 // The difference is that we want to make sure that our stubs work the same |
| 59 // way as chrome's implementation of WideToUTF8 and UTF8ToWide. |
| 60 for (size_t i = 0; i < arraysize(kConvertRoundtripCases); ++i) { |
| 61 std::ostringstream utf8_base, utf8_stub; |
| 62 utf8_base << WideToUTF8(kConvertRoundtripCases[i]); |
| 63 utf8_stub << icu_stubs::WideToUTF8(kConvertRoundtripCases[i]); |
| 64 |
| 65 EXPECT_EQ(utf8_base.str(), utf8_stub.str()); |
| 66 |
| 67 std::wostringstream wide_base, wide_stub; |
| 68 wide_base << UTF8ToWide(utf8_base.str()); |
| 69 wide_stub << icu_stubs::UTF8ToWide(utf8_base.str()); |
| 70 |
| 71 EXPECT_EQ(wide_base.str(), wide_stub.str()); |
| 72 } |
| 73 } |
OLD | NEW |