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

Side by Side Diff: sync/internal_api/public/base/ordinal_unittest.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 | Annotate | Revision Log
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "sync/internal_api/public/base/ordinal.h" 6 #include "sync/internal_api/public/base/ordinal.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cctype> 10 #include <cctype>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 LargeOrdinalkMidDigitValue_incorrect); 80 LargeOrdinalkMidDigitValue_incorrect);
81 COMPILE_ASSERT(LargeOrdinal::kMaxDigitValue == 255, 81 COMPILE_ASSERT(LargeOrdinal::kMaxDigitValue == 255,
82 LargeOrdinalkMaxDigitValue_incorrect); 82 LargeOrdinalkMaxDigitValue_incorrect);
83 COMPILE_ASSERT(LargeOrdinal::kRadix == 256, 83 COMPILE_ASSERT(LargeOrdinal::kRadix == 256,
84 LargeOrdinalkRadix_incorrect); 84 LargeOrdinalkRadix_incorrect);
85 85
86 // Create Ordinals that satisfy all but one criterion for validity. 86 // Create Ordinals that satisfy all but one criterion for validity.
87 // IsValid() should return false for all of them. 87 // IsValid() should return false for all of them.
88 TEST(Ordinal, Invalid) { 88 TEST(Ordinal, Invalid) {
89 // Length criterion. 89 // Length criterion.
90 EXPECT_FALSE(TestOrdinal("").IsValid()); 90 EXPECT_FALSE(TestOrdinal(std::string()).IsValid());
91 EXPECT_FALSE(LongOrdinal("0001").IsValid()); 91 EXPECT_FALSE(LongOrdinal("0001").IsValid());
92 92
93 const char kBeforeZero[] = { '0' - 1, '\0' }; 93 const char kBeforeZero[] = { '0' - 1, '\0' };
94 const char kAfterNine[] = { '9' + 1, '\0' }; 94 const char kAfterNine[] = { '9' + 1, '\0' };
95 95
96 // Character criterion. 96 // Character criterion.
97 EXPECT_FALSE(TestOrdinal(kBeforeZero).IsValid()); 97 EXPECT_FALSE(TestOrdinal(kBeforeZero).IsValid());
98 EXPECT_FALSE(TestOrdinal("4").IsValid()); 98 EXPECT_FALSE(TestOrdinal("4").IsValid());
99 EXPECT_FALSE(LongOrdinal(std::string("0000") + kBeforeZero).IsValid()); 99 EXPECT_FALSE(LongOrdinal(std::string("0000") + kBeforeZero).IsValid());
100 EXPECT_FALSE(LongOrdinal(std::string("0000") + kAfterNine).IsValid()); 100 EXPECT_FALSE(LongOrdinal(std::string("0000") + kAfterNine).IsValid());
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 std::vector<LongOrdinal> ordinals = sorted_ordinals; 367 std::vector<LongOrdinal> ordinals = sorted_ordinals;
368 std::random_shuffle(ordinals.begin(), ordinals.end()); 368 std::random_shuffle(ordinals.begin(), ordinals.end());
369 std::sort(ordinals.begin(), ordinals.end(), LongOrdinal::LessThanFn()); 369 std::sort(ordinals.begin(), ordinals.end(), LongOrdinal::LessThanFn());
370 EXPECT_TRUE(std::equal(ordinals.begin(), ordinals.end(), 370 EXPECT_TRUE(std::equal(ordinals.begin(), ordinals.end(),
371 sorted_ordinals.begin(), LongOrdinal::EqualsFn())); 371 sorted_ordinals.begin(), LongOrdinal::EqualsFn()));
372 } 372 }
373 373
374 } // namespace 374 } // namespace
375 375
376 } // namespace syncer 376 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698