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/syncable/syncable_id.h" | 5 #include "components/sync/syncable/syncable_id.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/test/values_test_util.h" | 9 #include "base/test/values_test_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "sync/test/engine/test_id_factory.h" | 11 #include "components/sync/test/engine/test_id_factory.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace syncer { | 14 namespace syncer { |
15 namespace syncable { | 15 namespace syncable { |
16 | 16 |
17 using std::vector; | 17 using std::vector; |
18 | 18 |
19 class SyncableIdTest : public testing::Test { }; | 19 class SyncableIdTest : public testing::Test {}; |
20 | 20 |
21 TEST(SyncableIdTest, TestIDCreation) { | 21 TEST(SyncableIdTest, TestIDCreation) { |
22 vector<Id> v; | 22 vector<Id> v; |
23 v.push_back(TestIdFactory::FromNumber(5)); | 23 v.push_back(TestIdFactory::FromNumber(5)); |
24 v.push_back(TestIdFactory::FromNumber(1)); | 24 v.push_back(TestIdFactory::FromNumber(1)); |
25 v.push_back(TestIdFactory::FromNumber(-5)); | 25 v.push_back(TestIdFactory::FromNumber(-5)); |
26 v.push_back(TestIdFactory::MakeLocal("A")); | 26 v.push_back(TestIdFactory::MakeLocal("A")); |
27 v.push_back(TestIdFactory::MakeLocal("B")); | 27 v.push_back(TestIdFactory::MakeLocal("B")); |
28 v.push_back(TestIdFactory::MakeServer("A")); | 28 v.push_back(TestIdFactory::MakeServer("A")); |
29 v.push_back(TestIdFactory::MakeServer("B")); | 29 v.push_back(TestIdFactory::MakeServer("B")); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 ASSERT_NE(*i, i->GetLexicographicSuccessor()); | 63 ASSERT_NE(*i, i->GetLexicographicSuccessor()); |
64 ASSERT_NE(i->GetLexicographicSuccessor(), *i); | 64 ASSERT_NE(i->GetLexicographicSuccessor(), *i); |
65 ASSERT_LT(*i, i->GetLexicographicSuccessor()); | 65 ASSERT_LT(*i, i->GetLexicographicSuccessor()); |
66 ASSERT_GT(i->GetLexicographicSuccessor(), *i); | 66 ASSERT_GT(i->GetLexicographicSuccessor(), *i); |
67 for (vector<Id>::iterator j = v.begin(); j != v.end(); ++j) { | 67 for (vector<Id>::iterator j = v.begin(); j != v.end(); ++j) { |
68 if (j == i) | 68 if (j == i) |
69 continue; | 69 continue; |
70 if (*j < *i) { | 70 if (*j < *i) { |
71 ASSERT_LT(j->GetLexicographicSuccessor(), *i); | 71 ASSERT_LT(j->GetLexicographicSuccessor(), *i); |
72 ASSERT_LT(j->GetLexicographicSuccessor(), | 72 ASSERT_LT(j->GetLexicographicSuccessor(), |
73 i->GetLexicographicSuccessor()); | 73 i->GetLexicographicSuccessor()); |
74 ASSERT_LT(*j, i->GetLexicographicSuccessor()); | 74 ASSERT_LT(*j, i->GetLexicographicSuccessor()); |
75 } else { | 75 } else { |
76 ASSERT_GT(j->GetLexicographicSuccessor(), *i); | 76 ASSERT_GT(j->GetLexicographicSuccessor(), *i); |
77 ASSERT_GT(j->GetLexicographicSuccessor(), | 77 ASSERT_GT(j->GetLexicographicSuccessor(), |
78 i->GetLexicographicSuccessor()); | 78 i->GetLexicographicSuccessor()); |
79 ASSERT_GT(*j, i->GetLexicographicSuccessor()); | 79 ASSERT_GT(*j, i->GetLexicographicSuccessor()); |
80 } | 80 } |
81 } | 81 } |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 TEST(SyncableIdTest, ToValue) { | 85 TEST(SyncableIdTest, ToValue) { |
86 base::ExpectStringValue("r", Id::CreateFromServerId("0").ToValue()); | 86 base::ExpectStringValue("r", Id::CreateFromServerId("0").ToValue()); |
87 base::ExpectStringValue("svalue", Id::CreateFromServerId("value").ToValue()); | 87 base::ExpectStringValue("svalue", Id::CreateFromServerId("value").ToValue()); |
88 | 88 |
89 base::ExpectStringValue("r", Id::CreateFromClientString("0").ToValue()); | 89 base::ExpectStringValue("r", Id::CreateFromClientString("0").ToValue()); |
90 base::ExpectStringValue("cvalue", | 90 base::ExpectStringValue("cvalue", |
91 Id::CreateFromClientString("value").ToValue()); | 91 Id::CreateFromClientString("value").ToValue()); |
92 } | 92 } |
93 | 93 |
94 } // namespace syncable | 94 } // namespace syncable |
95 } // namespace syncer | 95 } // namespace syncer |
OLD | NEW |