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

Side by Side Diff: base/strings/string_piece_unittest.cc

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 months 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
« no previous file with comments | « base/strings/nullable_string16.h ('k') | base/strings/string_split.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 595 }
596 596
597 TYPED_TEST(CommonStringPieceTest, CheckComparisons2) { 597 TYPED_TEST(CommonStringPieceTest, CheckComparisons2) {
598 TypeParam alphabet(TestFixture::as_string("abcdefghijklmnopqrstuvwxyz")); 598 TypeParam alphabet(TestFixture::as_string("abcdefghijklmnopqrstuvwxyz"));
599 TypeParam alphabet_z(TestFixture::as_string("abcdefghijklmnopqrstuvwxyzz")); 599 TypeParam alphabet_z(TestFixture::as_string("abcdefghijklmnopqrstuvwxyzz"));
600 TypeParam alphabet_y(TestFixture::as_string("abcdefghijklmnopqrstuvwxyy")); 600 TypeParam alphabet_y(TestFixture::as_string("abcdefghijklmnopqrstuvwxyy"));
601 BasicStringPiece<TypeParam> abc(alphabet); 601 BasicStringPiece<TypeParam> abc(alphabet);
602 602
603 // check comparison operations on strings longer than 4 bytes. 603 // check comparison operations on strings longer than 4 bytes.
604 ASSERT_TRUE(abc == BasicStringPiece<TypeParam>(alphabet)); 604 ASSERT_TRUE(abc == BasicStringPiece<TypeParam>(alphabet));
605 ASSERT_TRUE(abc.compare(BasicStringPiece<TypeParam>(alphabet)) == 0); 605 ASSERT_EQ(abc.compare(BasicStringPiece<TypeParam>(alphabet)), 0);
606 606
607 ASSERT_TRUE(abc < BasicStringPiece<TypeParam>(alphabet_z)); 607 ASSERT_TRUE(abc < BasicStringPiece<TypeParam>(alphabet_z));
608 ASSERT_TRUE(abc.compare(BasicStringPiece<TypeParam>(alphabet_z)) < 0); 608 ASSERT_LT(abc.compare(BasicStringPiece<TypeParam>(alphabet_z)), 0);
609 609
610 ASSERT_TRUE(abc > BasicStringPiece<TypeParam>(alphabet_y)); 610 ASSERT_TRUE(abc > BasicStringPiece<TypeParam>(alphabet_y));
611 ASSERT_TRUE(abc.compare(BasicStringPiece<TypeParam>(alphabet_y)) > 0); 611 ASSERT_GT(abc.compare(BasicStringPiece<TypeParam>(alphabet_y)), 0);
612 } 612 }
613 613
614 // Test operations only supported by std::string version. 614 // Test operations only supported by std::string version.
615 TEST(StringPieceTest, CheckComparisons2) { 615 TEST(StringPieceTest, CheckComparisons2) {
616 StringPiece abc("abcdefghijklmnopqrstuvwxyz"); 616 StringPiece abc("abcdefghijklmnopqrstuvwxyz");
617 617
618 // starts_with 618 // starts_with
619 ASSERT_TRUE(abc.starts_with(abc)); 619 ASSERT_TRUE(abc.starts_with(abc));
620 ASSERT_TRUE(abc.starts_with("abcdefghijklm")); 620 ASSERT_TRUE(abc.starts_with("abcdefghijklm"));
621 ASSERT_TRUE(!abc.starts_with("abcdefguvwxyz")); 621 ASSERT_TRUE(!abc.starts_with("abcdefguvwxyz"));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(NULL, 680 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(NULL,
681 static_cast<typename BasicStringPiece<TypeParam>::size_type>(0))); 681 static_cast<typename BasicStringPiece<TypeParam>::size_type>(0)));
682 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>()); 682 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>());
683 ASSERT_TRUE(str == BasicStringPiece<TypeParam>(str.begin(), str.end())); 683 ASSERT_TRUE(str == BasicStringPiece<TypeParam>(str.begin(), str.end()));
684 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(str.begin(), str.begin())); 684 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(str.begin(), str.begin()));
685 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(empty)); 685 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(empty));
686 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(empty.begin(), empty.end())); 686 ASSERT_TRUE(empty == BasicStringPiece<TypeParam>(empty.begin(), empty.end()));
687 } 687 }
688 688
689 } // namespace base 689 } // namespace base
OLDNEW
« no previous file with comments | « base/strings/nullable_string16.h ('k') | base/strings/string_split.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698