Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 } | 394 } |
| 395 | 395 |
| 396 TEST(StringTest, Lower) | 396 TEST(StringTest, Lower) |
| 397 { | 397 { |
| 398 EXPECT_STREQ("link", String("LINK").lower().ascii().data()); | 398 EXPECT_STREQ("link", String("LINK").lower().ascii().data()); |
| 399 EXPECT_STREQ("link", String("lInk").lower().ascii().data()); | 399 EXPECT_STREQ("link", String("lInk").lower().ascii().data()); |
| 400 EXPECT_STREQ("lin\xE1k", String("lIn\xC1k").lower().latin1().data()); | 400 EXPECT_STREQ("lin\xE1k", String("lIn\xC1k").lower().latin1().data()); |
| 401 EXPECT_STREQ("link", String::fromUTF8("LIN\xE2\x84\xAA").lower().utf8().data ()); | 401 EXPECT_STREQ("link", String::fromUTF8("LIN\xE2\x84\xAA").lower().utf8().data ()); |
| 402 } | 402 } |
| 403 | 403 |
| 404 TEST(StringTest, fromUTF8Lenient) | |
|
jsbell
2016/03/08 20:28:15
Nit: test name capitalized?
(I know this matches
horo
2016/03/09 01:58:40
Done.
| |
| 405 { | |
| 406 UChar buffer[] = {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0xd8 00 /* surrogate value */}; | |
| 407 String utf16String(buffer, sizeof(buffer) / sizeof(UChar)); | |
| 408 ASSERT_FALSE(utf16String.isNull()); | |
| 409 | |
| 410 std::string utf8String(utf16String.utf8().data()); | |
| 411 ASSERT_TRUE(String::fromUTF8(utf8String.data()).isNull()); | |
| 412 String utf16NewString = String::fromUTF8Lenient(utf8String.data(), utf8Strin g.length()); | |
|
jsbell
2016/03/08 20:28:15
In addition to testing that fromUTF8Lenient lets t
horo
2016/03/09 01:58:40
Done.
| |
| 413 ASSERT_FALSE(utf16NewString.isNull()); | |
| 414 ASSERT_EQ(utf16String, utf16NewString); | |
| 415 } | |
| 416 | |
| 404 } // namespace WTF | 417 } // namespace WTF |
| OLD | NEW |