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 "sync/internal_api/public/base/node_ordinal.h" | 5 #include "components/sync/base/node_ordinal.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cstddef> | 10 #include <cstddef> |
11 #include <functional> | 11 #include <functional> |
12 #include <limits> | 12 #include <limits> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // value should be equal to the original value. | 93 // value should be equal to the original value. |
94 TEST(NodeOrdinalTest, PositionToOrdinalToPosition) { | 94 TEST(NodeOrdinalTest, PositionToOrdinalToPosition) { |
95 for (size_t i = 0; i < kNumTestValues; ++i) { | 95 for (size_t i = 0; i < kNumTestValues; ++i) { |
96 const int64_t expected_value = kTestValues[i]; | 96 const int64_t expected_value = kTestValues[i]; |
97 const NodeOrdinal ordinal = Int64ToNodeOrdinal(expected_value); | 97 const NodeOrdinal ordinal = Int64ToNodeOrdinal(expected_value); |
98 const int64_t value = NodeOrdinalToInt64(ordinal); | 98 const int64_t value = NodeOrdinalToInt64(ordinal); |
99 EXPECT_EQ(expected_value, value) << "i = " << i; | 99 EXPECT_EQ(expected_value, value) << "i = " << i; |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 template <typename T, typename LessThan = std::less<T> > | 103 template <typename T, typename LessThan = std::less<T>> |
104 class IndexedLessThan { | 104 class IndexedLessThan { |
105 public: | 105 public: |
106 explicit IndexedLessThan(const T* values) : values_(values) {} | 106 explicit IndexedLessThan(const T* values) : values_(values) {} |
107 | 107 |
108 bool operator()(int i1, int i2) { | 108 bool operator()(int i1, int i2) { |
109 return less_than_(values_[i1], values_[i2]); | 109 return less_than_(values_[i1], values_[i2]); |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
113 const T* values_; | 113 const T* values_; |
(...skipping 26 matching lines...) Expand all Loading... |
140 TEST(NodeOrdinalTest, CreateBetween) { | 140 TEST(NodeOrdinalTest, CreateBetween) { |
141 const NodeOrdinal ordinal1("\1\1\1\1\1\1\1\1"); | 141 const NodeOrdinal ordinal1("\1\1\1\1\1\1\1\1"); |
142 const NodeOrdinal ordinal2("\1\1\1\1\1\1\1\3"); | 142 const NodeOrdinal ordinal2("\1\1\1\1\1\1\1\3"); |
143 EXPECT_EQ("\1\1\1\1\1\1\1\2", | 143 EXPECT_EQ("\1\1\1\1\1\1\1\2", |
144 ordinal1.CreateBetween(ordinal2).ToInternalValue()); | 144 ordinal1.CreateBetween(ordinal2).ToInternalValue()); |
145 } | 145 } |
146 | 146 |
147 } // namespace | 147 } // namespace |
148 | 148 |
149 } // namespace syncer | 149 } // namespace syncer |
OLD | NEW |