Commit d81ba3f1 authored by jamesge's avatar jamesge

fix CaseIgnoredFlatSet

parent 8eabe513
...@@ -64,7 +64,7 @@ template <typename T> ...@@ -64,7 +64,7 @@ template <typename T>
class CaseIgnoredFlatMap : public butil::FlatMap< class CaseIgnoredFlatMap : public butil::FlatMap<
std::string, T, CaseIgnoredHasher, CaseIgnoredEqual> {}; std::string, T, CaseIgnoredHasher, CaseIgnoredEqual> {};
class CaseIgnoredFlatSet : public butil::FlatMap< class CaseIgnoredFlatSet : public butil::FlatSet<
std::string, CaseIgnoredHasher, CaseIgnoredEqual> {}; std::string, CaseIgnoredHasher, CaseIgnoredEqual> {};
} // namespace butil } // namespace butil
......
...@@ -241,20 +241,40 @@ TEST_F(FlatMapTest, __builtin_ctzl_perf) { ...@@ -241,20 +241,40 @@ TEST_F(FlatMapTest, __builtin_ctzl_perf) {
} }
TEST_F(FlatMapTest, case_ignored_map) { TEST_F(FlatMapTest, case_ignored_map) {
butil::Timer tm;
tm.start();
butil::CaseIgnoredFlatMap<int> m1; butil::CaseIgnoredFlatMap<int> m1;
ASSERT_EQ(0, m1.init(32)); ASSERT_EQ(0, m1.init(32));
m1["Content-Type"] = 1; m1["Content-Type"] = 1;
m1["content-Type"] = 10;
m1["Host"] = 2; m1["Host"] = 2;
m1["HOST"] = 20;
m1["Cache-Control"] = 3; m1["Cache-Control"] = 3;
ASSERT_EQ(1, m1["cONTENT-tYPE"]); m1["CachE-ControL"] = 30;
ASSERT_EQ(2, m1["hOST"]); ASSERT_EQ(10, m1["cONTENT-tYPE"]);
ASSERT_EQ(3, m1["cache-control"]); ASSERT_EQ(20, m1["hOST"]);
tm.stop(); ASSERT_EQ(30, m1["cache-control"]);
std::cout << tm.n_elapsed() << std::endl;
} }
TEST_F(FlatMapTest, case_ignored_set) {
butil::CaseIgnoredFlatSet s1;
ASSERT_EQ(0, s1.init(32));
s1.insert("Content-Type");
ASSERT_EQ(1ul, s1.size());
s1.insert("Content-TYPE");
ASSERT_EQ(1ul, s1.size());
s1.insert("Host");
ASSERT_EQ(2ul, s1.size());
s1.insert("HOST");
ASSERT_EQ(2ul, s1.size());
s1.insert("Cache-Control");
ASSERT_EQ(3ul, s1.size());
s1.insert("CachE-ControL");
ASSERT_EQ(3ul, s1.size());
ASSERT_TRUE(s1.seek("cONTENT-tYPE"));
ASSERT_TRUE(s1.seek("hOST"));
ASSERT_TRUE(s1.seek("cache-control"));
}
TEST_F(FlatMapTest, make_sure_all_methods_compile) { TEST_F(FlatMapTest, make_sure_all_methods_compile) {
typedef butil::FlatMap<int, long> M1; typedef butil::FlatMap<int, long> M1;
M1 m1; M1 m1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment