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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/syncable/syncable_id_unittest.cc
diff --git a/chrome/browser/sync/syncable/syncable_id_unittest.cc b/chrome/browser/sync/syncable/syncable_id_unittest.cc
index b592ad511c18207ff021c460a8d6371667afcf3b..77517c7d4749c7a2d5f0852cc19976b696465af0 100644
--- a/chrome/browser/sync/syncable/syncable_id_unittest.cc
+++ b/chrome/browser/sync/syncable/syncable_id_unittest.cc
@@ -41,4 +41,44 @@ TEST(SyncableIdTest, TestIDCreation) {
}
}
+TEST(SyncableIdTest, GetLeastIdForLexicographicComparison) {
+ vector<Id> v;
+ v.push_back(Id::CreateFromServerId("z5"));
+ v.push_back(Id::CreateFromServerId("z55"));
+ v.push_back(Id::CreateFromServerId("z6"));
+ v.push_back(Id::CreateFromClientString("zA-"));
+ v.push_back(Id::CreateFromClientString("zA--"));
+ v.push_back(Id::CreateFromServerId("zA--"));
+
+ for (int i = 0; i <= 255; ++i) {
+ std::string one_character_id;
+ one_character_id.push_back(i);
+ v.push_back(Id::CreateFromClientString(one_character_id));
+ }
+
+ for (vector<Id>::iterator i = v.begin(); i != v.end(); ++i) {
+ // The following looks redundant, but we're testing a custom operator<.
+ ASSERT_LT(Id::GetLeastIdForLexicographicComparison(), *i);
+ ASSERT_NE(*i, i->GetLexicographicSuccessor());
+ ASSERT_NE(i->GetLexicographicSuccessor(), *i);
+ ASSERT_LT(*i, i->GetLexicographicSuccessor());
+ ASSERT_GT(i->GetLexicographicSuccessor(), *i);
+ for (vector<Id>::iterator j = v.begin(); j != v.end(); ++j) {
+ if (j == i)
+ continue;
+ if (*j < *i) {
+ ASSERT_LT(j->GetLexicographicSuccessor(), *i);
+ ASSERT_LT(j->GetLexicographicSuccessor(),
+ i->GetLexicographicSuccessor());
+ ASSERT_LT(*j, i->GetLexicographicSuccessor());
+ } else {
+ ASSERT_GT(j->GetLexicographicSuccessor(), *i);
+ ASSERT_GT(j->GetLexicographicSuccessor(),
+ i->GetLexicographicSuccessor());
+ ASSERT_GT(*j, i->GetLexicographicSuccessor());
+ }
+ }
+ }
+}
+
} // namespace syncable
« 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