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

Unified Diff: chrome/common/string_index_unittest.cc

Issue 8236002: Create StringOrdinal to allow placement of strings in sorted lists (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 2 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
« chrome/common/string_index.cc ('K') | « chrome/common/string_index.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/string_index_unittest.cc
diff --git a/chrome/common/string_index_unittest.cc b/chrome/common/string_index_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0e126d2e1190eb5abba2b38ad8d3330f174523d3
--- /dev/null
+++ b/chrome/common/string_index_unittest.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/string_index.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+
+class StringIndexTest: public testing::Test {
+ protected:
+ StringIndex string_index_;
+};
+
+TEST_F(StringIndexTest, CreateStringBetweenSingleDigit) {
+ EXPECT_EQ("C", string_index_.CreateStringBetween("B", "D"));
+ EXPECT_EQ("C", string_index_.CreateStringBetween("B", "E"));
+ EXPECT_EQ("D", string_index_.CreateStringBetween("B", "F"));
+
+ EXPECT_EQ("BM", string_index_.CreateStringBetween("B","C"));
+ EXPECT_EQ("CM", string_index_.CreateStringBetween("C","D"));
+}
+
+TEST_F(StringIndexTest, CreateStringBetweenEnd) {
+ EXPECT_EQ("ZM", string_index_.CreateStringBetween("Z", ""));
+ EXPECT_EQ("ZZM", string_index_.CreateStringBetween("ZZ", ""));
+ EXPECT_EQ("ZZZYM", string_index_.CreateStringBetween("ZZZY",""));
+ EXPECT_EQ("ZL", string_index_.CreateStringBetween("YY",""));
+}
+
+TEST_F(StringIndexTest, CreateStringBetweenStart) {
+ EXPECT_EQ("AM", string_index_.CreateStringBetween("", "B"));
+ EXPECT_EQ("AM", string_index_.CreateStringBetween("", "BB"));
+ EXPECT_EQ("AN", string_index_.CreateStringBetween("", "BC"));
+ EXPECT_EQ("AN", string_index_.CreateStringBetween("", "BD"));
+}
+
+TEST_F(StringIndexTest, CreateStringBetweenLastDigitTheSame) {
+ EXPECT_EQ("AN", string_index_.CreateStringBetween("AB", "BB"));
+ EXPECT_EQ("BN", string_index_.CreateStringBetween("BB", "CB"));
+ EXPECT_EQ("BBN", string_index_.CreateStringBetween("BBB", "BCB"));
+}
« chrome/common/string_index.cc ('K') | « chrome/common/string_index.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698