You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by ja...@apache.org on 2020/01/16 04:54:01 UTC
[incubator-brpc] branch master updated: fix CaseIgnoredFlatSet
This is an automated email from the ASF dual-hosted git repository.
jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git
The following commit(s) were added to refs/heads/master by this push:
new d81ba3f fix CaseIgnoredFlatSet
d81ba3f is described below
commit d81ba3f1bc6a7f4bd09439798678733d24e6a729
Author: jamesge <jg...@gmail.com>
AuthorDate: Thu Jan 16 12:53:44 2020 +0800
fix CaseIgnoredFlatSet
---
src/butil/containers/case_ignored_flat_map.h | 2 +-
test/flat_map_unittest.cpp | 34 ++++++++++++++++++++++------
2 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/src/butil/containers/case_ignored_flat_map.h b/src/butil/containers/case_ignored_flat_map.h
index 99add6c..ed6e58b 100644
--- a/src/butil/containers/case_ignored_flat_map.h
+++ b/src/butil/containers/case_ignored_flat_map.h
@@ -64,7 +64,7 @@ template <typename T>
class CaseIgnoredFlatMap : public butil::FlatMap<
std::string, T, CaseIgnoredHasher, CaseIgnoredEqual> {};
-class CaseIgnoredFlatSet : public butil::FlatMap<
+class CaseIgnoredFlatSet : public butil::FlatSet<
std::string, CaseIgnoredHasher, CaseIgnoredEqual> {};
} // namespace butil
diff --git a/test/flat_map_unittest.cpp b/test/flat_map_unittest.cpp
index 6bcd795..6b6e360 100644
--- a/test/flat_map_unittest.cpp
+++ b/test/flat_map_unittest.cpp
@@ -241,20 +241,40 @@ TEST_F(FlatMapTest, __builtin_ctzl_perf) {
}
TEST_F(FlatMapTest, case_ignored_map) {
- butil::Timer tm;
- tm.start();
butil::CaseIgnoredFlatMap<int> m1;
ASSERT_EQ(0, m1.init(32));
m1["Content-Type"] = 1;
+ m1["content-Type"] = 10;
m1["Host"] = 2;
+ m1["HOST"] = 20;
m1["Cache-Control"] = 3;
- ASSERT_EQ(1, m1["cONTENT-tYPE"]);
- ASSERT_EQ(2, m1["hOST"]);
- ASSERT_EQ(3, m1["cache-control"]);
- tm.stop();
- std::cout << tm.n_elapsed() << std::endl;
+ m1["CachE-ControL"] = 30;
+ ASSERT_EQ(10, m1["cONTENT-tYPE"]);
+ ASSERT_EQ(20, m1["hOST"]);
+ ASSERT_EQ(30, m1["cache-control"]);
}
+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) {
typedef butil::FlatMap<int, long> M1;
M1 m1;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org