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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 | 747 |
748 TEST(StringPiece16Test, CheckNULL) { | 748 TEST(StringPiece16Test, CheckNULL) { |
749 StringPiece16 s(NULL); | 749 StringPiece16 s(NULL); |
750 ASSERT_EQ(s.data(), (const char16*)NULL); | 750 ASSERT_EQ(s.data(), (const char16*)NULL); |
751 ASSERT_EQ(s.size(), 0U); | 751 ASSERT_EQ(s.size(), 0U); |
752 | 752 |
753 s.set(NULL); | 753 s.set(NULL); |
754 ASSERT_EQ(s.data(), (const char16*)NULL); | 754 ASSERT_EQ(s.data(), (const char16*)NULL); |
755 ASSERT_EQ(s.size(), 0U); | 755 ASSERT_EQ(s.size(), 0U); |
756 | 756 |
757 string16 str = s.as_string16(); | 757 string16 str = s.as_string(); |
758 ASSERT_EQ(s.data(), (const char16*)NULL); | 758 ASSERT_EQ(s.data(), (const char16*)NULL); |
759 ASSERT_EQ(s.size(), 0U); | 759 ASSERT_EQ(s.size(), 0U); |
760 } | 760 } |
761 | 761 |
762 TEST(StringPiece16Test, HeterogenousStringPieceEquals) { | 762 TEST(StringPiece16Test, HeterogenousStringPieceEquals) { |
763 ASSERT_TRUE(StringPiece16(ASCIIToUTF16("hello")) == ASCIIToUTF16("hello")); | 763 ASSERT_TRUE(StringPiece16(ASCIIToUTF16("hello")) == ASCIIToUTF16("hello")); |
764 } | 764 } |
765 | 765 |
766 TEST(StringPiece16Test, CheckConversion) { | 766 TEST(StringPiece16Test, CheckConversion) { |
767 // Make sure that we can convert from UTF8 to UTF16 and back. We use a two | 767 // Make sure that we can convert from UTF8 to UTF16 and back. We use a two |
768 // byte character (G clef) to test this. | 768 // byte character (G clef) to test this. |
769 ASSERT_EQ( | 769 ASSERT_EQ( |
770 UTF16ToUTF8( | 770 UTF16ToUTF8( |
771 StringPiece16(UTF8ToUTF16("\xf0\x9d\x84\x9e")).as_string16()), | 771 StringPiece16(UTF8ToUTF16("\xf0\x9d\x84\x9e")).as_string()), |
772 "\xf0\x9d\x84\x9e"); | 772 "\xf0\x9d\x84\x9e"); |
773 } | 773 } |
774 | 774 |
775 } // namespace base | 775 } // namespace base |
OLD | NEW |