OLD | NEW |
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" | |
6 #include "sync/internal_api/public/base/ordinal.h" | 5 #include "sync/internal_api/public/base/ordinal.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 6 |
| 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cctype> | 10 #include <cctype> |
11 #include <cstddef> | 11 #include <cstddef> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
| 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 |
15 namespace syncer { | 17 namespace syncer { |
16 | 18 |
17 namespace { | 19 namespace { |
18 | 20 |
19 struct TestOrdinalTraits { | 21 struct TestOrdinalTraits { |
20 static const uint8 kZeroDigit = '0'; | 22 static const uint8_t kZeroDigit = '0'; |
21 static const uint8 kMaxDigit = '3'; | 23 static const uint8_t kMaxDigit = '3'; |
22 static const size_t kMinLength = 1; | 24 static const size_t kMinLength = 1; |
23 }; | 25 }; |
24 | 26 |
25 struct LongOrdinalTraits { | 27 struct LongOrdinalTraits { |
26 static const uint8 kZeroDigit = '0'; | 28 static const uint8_t kZeroDigit = '0'; |
27 static const uint8 kMaxDigit = '9'; | 29 static const uint8_t kMaxDigit = '9'; |
28 static const size_t kMinLength = 5; | 30 static const size_t kMinLength = 5; |
29 }; | 31 }; |
30 | 32 |
31 struct LargeOrdinalTraits { | 33 struct LargeOrdinalTraits { |
32 static const uint8 kZeroDigit = 0; | 34 static const uint8_t kZeroDigit = 0; |
33 static const uint8 kMaxDigit = kuint8max; | 35 static const uint8_t kMaxDigit = UINT8_MAX; |
34 static const size_t kMinLength = 1; | 36 static const size_t kMinLength = 1; |
35 }; | 37 }; |
36 | 38 |
37 typedef Ordinal<TestOrdinalTraits> TestOrdinal; | 39 typedef Ordinal<TestOrdinalTraits> TestOrdinal; |
38 typedef Ordinal<LongOrdinalTraits> LongOrdinal; | 40 typedef Ordinal<LongOrdinalTraits> LongOrdinal; |
39 typedef Ordinal<LargeOrdinalTraits> LargeOrdinal; | 41 typedef Ordinal<LargeOrdinalTraits> LargeOrdinal; |
40 | 42 |
41 static_assert(TestOrdinal::kZeroDigit == '0', | 43 static_assert(TestOrdinal::kZeroDigit == '0', |
42 "incorrect TestOrdinal zero digit"); | 44 "incorrect TestOrdinal zero digit"); |
43 static_assert(TestOrdinal::kOneDigit == '1', | 45 static_assert(TestOrdinal::kOneDigit == '1', |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 std::vector<LongOrdinal> ordinals = sorted_ordinals; | 369 std::vector<LongOrdinal> ordinals = sorted_ordinals; |
368 std::random_shuffle(ordinals.begin(), ordinals.end()); | 370 std::random_shuffle(ordinals.begin(), ordinals.end()); |
369 std::sort(ordinals.begin(), ordinals.end(), LongOrdinal::LessThanFn()); | 371 std::sort(ordinals.begin(), ordinals.end(), LongOrdinal::LessThanFn()); |
370 EXPECT_TRUE(std::equal(ordinals.begin(), ordinals.end(), | 372 EXPECT_TRUE(std::equal(ordinals.begin(), ordinals.end(), |
371 sorted_ordinals.begin(), LongOrdinal::EqualsFn())); | 373 sorted_ordinals.begin(), LongOrdinal::EqualsFn())); |
372 } | 374 } |
373 | 375 |
374 } // namespace | 376 } // namespace |
375 | 377 |
376 } // namespace syncer | 378 } // namespace syncer |
OLD | NEW |