Commit 0e34d130 authored by Simon Giesecke's avatar Simon Giesecke

Problem: insufficient unit tests for mtrie

Solution: added unit test and assertions
parent 506f0e5c
...@@ -231,7 +231,6 @@ void test_rm_nonexistent_between () ...@@ -231,7 +231,6 @@ void test_rm_nonexistent_between ()
add_indexed_expect_unique (mtrie, pipes, names, 0); add_indexed_expect_unique (mtrie, pipes, names, 0);
add_indexed_expect_unique (mtrie, pipes, names, 2); add_indexed_expect_unique (mtrie, pipes, names, 2);
const zmq::generic_mtrie_t<int>::prefix_t name_data = const zmq::generic_mtrie_t<int>::prefix_t name_data =
reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (names[1]); reinterpret_cast<zmq::generic_mtrie_t<int>::prefix_t> (names[1]);
...@@ -248,6 +247,33 @@ void test_add_multiple () ...@@ -248,6 +247,33 @@ void test_add_multiple ()
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
add_indexed_expect_unique (mtrie, pipes, names, 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 () void test_rm_multiple_in_order ()
...@@ -313,6 +339,7 @@ int main (void) ...@@ -313,6 +339,7 @@ int main (void)
RUN_TEST (test_rm_nonexistent_between); RUN_TEST (test_rm_nonexistent_between);
RUN_TEST (test_add_multiple); RUN_TEST (test_add_multiple);
RUN_TEST (test_add_multiple_reverse);
RUN_TEST (test_rm_multiple_in_order); RUN_TEST (test_rm_multiple_in_order);
RUN_TEST (test_rm_multiple_reverse_order); RUN_TEST (test_rm_multiple_reverse_order);
......
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