Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: base/string_piece_unittest.cc

Issue 8846001: Add iterator range constructors to StringPiece. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove extra blank line. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/string_piece.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « base/string_piece.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698