| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "public/platform/WebString.h" | 5 #include "public/platform/WebString.h" |
| 6 | 6 |
| 7 #include "platform/wtf/text/WTFString.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "wtf/text/WTFString.h" | |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 TEST(WebStringTest, UTF8ConversionRoundTrip) { | 12 TEST(WebStringTest, UTF8ConversionRoundTrip) { |
| 13 // Valid characters. | 13 // Valid characters. |
| 14 for (UChar uchar = 0; uchar <= 0xD7FF; ++uchar) { | 14 for (UChar uchar = 0; uchar <= 0xD7FF; ++uchar) { |
| 15 WebString utf16String(&uchar, 1); | 15 WebString utf16String(&uchar, 1); |
| 16 std::string utf8String(utf16String.utf8()); | 16 std::string utf8String(utf16String.utf8()); |
| 17 WebString utf16NewString = | 17 WebString utf16NewString = |
| 18 WebString::fromUTF8(utf8String.data(), utf8String.length()); | 18 WebString::fromUTF8(utf8String.data(), utf8String.length()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 41 WebString::UTF8ConversionMode::kStrictReplacingErrorsWithFFFD); | 41 WebString::UTF8ConversionMode::kStrictReplacingErrorsWithFFFD); |
| 42 EXPECT_FALSE(utf8String.empty()); | 42 EXPECT_FALSE(utf8String.empty()); |
| 43 utf16NewString = | 43 utf16NewString = |
| 44 WebString::fromUTF8(utf8String.data(), utf8String.length()); | 44 WebString::fromUTF8(utf8String.data(), utf8String.length()); |
| 45 EXPECT_FALSE(utf16NewString.isNull()); | 45 EXPECT_FALSE(utf16NewString.isNull()); |
| 46 EXPECT_FALSE(utf16String == utf16NewString); | 46 EXPECT_FALSE(utf16String == utf16NewString); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace blink | 50 } // namespace blink |
| OLD | NEW |