OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/string16.h" | 7 #include "base/string16.h" |
8 #include "base/string_piece.h" | 8 #include "base/string_piece.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 646 |
647 TEST(StringPiece16Test, CheckConversion) { | 647 TEST(StringPiece16Test, CheckConversion) { |
648 // Make sure that we can convert from UTF8 to UTF16 and back. We use a two | 648 // Make sure that we can convert from UTF8 to UTF16 and back. We use a two |
649 // byte character (G clef) to test this. | 649 // byte character (G clef) to test this. |
650 ASSERT_EQ( | 650 ASSERT_EQ( |
651 UTF16ToUTF8( | 651 UTF16ToUTF8( |
652 StringPiece16(UTF8ToUTF16("\xf0\x9d\x84\x9e")).as_string()), | 652 StringPiece16(UTF8ToUTF16("\xf0\x9d\x84\x9e")).as_string()), |
653 "\xf0\x9d\x84\x9e"); | 653 "\xf0\x9d\x84\x9e"); |
654 } | 654 } |
655 | 655 |
| 656 TYPED_TEST(CommonStringPieceTest, CheckConstructors) { |
| 657 TypeParam str(TestFixture::as_string("hello world")); |
| 658 TypeParam empty; |
| 659 |
| 660 ASSERT_TRUE(str == BasicStringPiece<TypeParam>(str)); |
| 661 ASSERT_TRUE(str == BasicStringPiece<TypeParam>(str.c_str())); |
| 662 ASSERT_TRUE(TestFixture::as_string("hello") == |
| 663 BasicStringPiece<TypeParam>(str.c_str(), 5)); |
| 664 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(str.c_str(), 0)); |
| 665 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(NULL)); |
| 666 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(NULL, 0)); |
| 667 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>()); |
| 668 ASSERT_TRUE(str == BasicStringPiece<TypeParam>(str.begin(), str.end())); |
| 669 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(str.begin(), str.begin())); |
| 670 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(empty)); |
| 671 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(empty.begin(), empty.end())); |
| 672 } |
| 673 |
656 } // namespace base | 674 } // namespace base |
OLD | NEW |