Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
d81ba3f1
Commit
d81ba3f1
authored
Jan 16, 2020
by
jamesge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix CaseIgnoredFlatSet
parent
8eabe513
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
8 deletions
+28
-8
case_ignored_flat_map.h
src/butil/containers/case_ignored_flat_map.h
+1
-1
flat_map_unittest.cpp
test/flat_map_unittest.cpp
+27
-7
No files found.
src/butil/containers/case_ignored_flat_map.h
View file @
d81ba3f1
...
...
@@ -64,7 +64,7 @@ template <typename T>
class
CaseIgnoredFlatMap
:
public
butil
::
FlatMap
<
std
::
string
,
T
,
CaseIgnoredHasher
,
CaseIgnoredEqual
>
{};
class
CaseIgnoredFlatSet
:
public
butil
::
Flat
Map
<
class
CaseIgnoredFlatSet
:
public
butil
::
Flat
Set
<
std
::
string
,
CaseIgnoredHasher
,
CaseIgnoredEqual
>
{};
}
// namespace butil
...
...
test/flat_map_unittest.cpp
View file @
d81ba3f1
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment