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

Side by Side Diff: chrome/browser/sync/syncable/syncable_id_unittest.cc

Issue 6588119: First-time sync: asymptotic running time improvement (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/Release
Patch Set: Fix test bug. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/sync/syncable/syncable_id.h" 5 #include "chrome/browser/sync/syncable/syncable_id.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "chrome/test/sync/engine/test_id_factory.h" 9 #include "chrome/test/sync/engine/test_id_factory.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 23 matching lines...) Expand all
34 for (vector<Id>::iterator j = v.begin(); j != i; ++j) { 34 for (vector<Id>::iterator j = v.begin(); j != i; ++j) {
35 ASSERT_NE(*i, *j) << "mis equated two distinct ids"; 35 ASSERT_NE(*i, *j) << "mis equated two distinct ids";
36 } 36 }
37 ASSERT_EQ(*i, *i) << "self-equality failed"; 37 ASSERT_EQ(*i, *i) << "self-equality failed";
38 Id copy1 = *i; 38 Id copy1 = *i;
39 Id copy2 = *i; 39 Id copy2 = *i;
40 ASSERT_EQ(copy1, copy2) << "equality after copy failed"; 40 ASSERT_EQ(copy1, copy2) << "equality after copy failed";
41 } 41 }
42 } 42 }
43 43
44 TEST(SyncableIdTest, GetLeastIdForLexicographicComparison) {
45 vector<Id> v;
46 v.push_back(Id::CreateFromServerId("z5"));
47 v.push_back(Id::CreateFromServerId("z55"));
48 v.push_back(Id::CreateFromServerId("z6"));
49 v.push_back(Id::CreateFromClientString("zA-"));
50 v.push_back(Id::CreateFromClientString("zA--"));
51 v.push_back(Id::CreateFromServerId("zA--"));
52
53 for (int i = 0; i <= 255; ++i) {
54 std::string one_character_id;
55 one_character_id.push_back(i);
56 v.push_back(Id::CreateFromClientString(one_character_id));
57 }
58
59 for (vector<Id>::iterator i = v.begin(); i != v.end(); ++i) {
60 // The following looks redundant, but we're testing a custom operator<.
61 ASSERT_LT(Id::GetLeastIdForLexicographicComparison(), *i);
62 ASSERT_NE(*i, i->GetLexicographicSuccessor());
63 ASSERT_NE(i->GetLexicographicSuccessor(), *i);
64 ASSERT_LT(*i, i->GetLexicographicSuccessor());
65 ASSERT_GT(i->GetLexicographicSuccessor(), *i);
66 for (vector<Id>::iterator j = v.begin(); j != v.end(); ++j) {
67 if (j == i)
68 continue;
69 if (*j < *i) {
70 ASSERT_LT(j->GetLexicographicSuccessor(), *i);
71 ASSERT_LT(j->GetLexicographicSuccessor(),
72 i->GetLexicographicSuccessor());
73 ASSERT_LT(*j, i->GetLexicographicSuccessor());
74 } else {
75 ASSERT_GT(j->GetLexicographicSuccessor(), *i);
76 ASSERT_GT(j->GetLexicographicSuccessor(),
77 i->GetLexicographicSuccessor());
78 ASSERT_GT(*j, i->GetLexicographicSuccessor());
79 }
80 }
81 }
82 }
83
44 } // namespace syncable 84 } // namespace syncable
OLDNEW
« no previous file with comments | « chrome/browser/sync/syncable/syncable_id.cc ('k') | chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698