Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
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
libzmq
Commits
0e34d130
Commit
0e34d130
authored
Feb 18, 2018
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: insufficient unit tests for mtrie
Solution: added unit test and assertions
parent
506f0e5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletion
+28
-1
unittest_mtrie.cpp
unittests/unittest_mtrie.cpp
+28
-1
No files found.
unittests/unittest_mtrie.cpp
View file @
0e34d130
...
...
@@ -231,7 +231,6 @@ void test_rm_nonexistent_between ()
add_indexed_expect_unique
(
mtrie
,
pipes
,
names
,
0
);
add_indexed_expect_unique
(
mtrie
,
pipes
,
names
,
2
);
const
zmq
::
generic_mtrie_t
<
int
>::
prefix_t
name_data
=
reinterpret_cast
<
zmq
::
generic_mtrie_t
<
int
>::
prefix_t
>
(
names
[
1
]);
...
...
@@ -248,6 +247,33 @@ void test_add_multiple ()
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
add_indexed_expect_unique
(
mtrie
,
pipes
,
names
,
i
);
}
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
const
zmq
::
generic_mtrie_t
<
int
>::
prefix_t
name_data
=
reinterpret_cast
<
zmq
::
generic_mtrie_t
<
int
>::
prefix_t
>
(
names
[
i
]);
int
count
=
0
;
mtrie
.
match
(
name_data
,
getlen
(
name_data
),
mtrie_count
,
&
count
);
TEST_ASSERT_EQUAL_INT
(
1
,
count
);
}
}
void
test_add_multiple_reverse
()
{
int
pipes
[
3
];
const
char
*
names
[
3
]
=
{
"foo1"
,
"foo2"
,
"foo3"
};
zmq
::
generic_mtrie_t
<
int
>
mtrie
;
for
(
int
i
=
2
;
i
>=
0
;
--
i
)
{
add_indexed_expect_unique
(
mtrie
,
pipes
,
names
,
i
);
}
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
const
zmq
::
generic_mtrie_t
<
int
>::
prefix_t
name_data
=
reinterpret_cast
<
zmq
::
generic_mtrie_t
<
int
>::
prefix_t
>
(
names
[
i
]);
int
count
=
0
;
mtrie
.
match
(
name_data
,
getlen
(
name_data
),
mtrie_count
,
&
count
);
TEST_ASSERT_EQUAL_INT
(
1
,
count
);
}
}
void
test_rm_multiple_in_order
()
...
...
@@ -313,6 +339,7 @@ int main (void)
RUN_TEST
(
test_rm_nonexistent_between
);
RUN_TEST
(
test_add_multiple
);
RUN_TEST
(
test_add_multiple_reverse
);
RUN_TEST
(
test_rm_multiple_in_order
);
RUN_TEST
(
test_rm_multiple_reverse_order
);
...
...
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