From b42a59a839bf2528d538eda78158f0da787755e7 Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Fri, 16 Feb 2018 13:21:50 +0100 Subject: [PATCH] Problem: insufficient unit tests for mtrie Solution: added test case --- unittests/unittest_mtrie.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/unittests/unittest_mtrie.cpp b/unittests/unittest_mtrie.cpp index e095694c..544b0d00 100644 --- a/unittests/unittest_mtrie.cpp +++ b/unittests/unittest_mtrie.cpp @@ -143,6 +143,21 @@ void test_add_rm_single_entry_match_exact () TEST_ASSERT_EQUAL_INT (0, count); } +void test_rm_empty () +{ + int pipe; + zmq::generic_mtrie_t mtrie; + const zmq::generic_mtrie_t::prefix_t test_name = + reinterpret_cast::prefix_t> ("foo"); + + bool res = mtrie.rm (test_name, getlen (test_name), &pipe); + TEST_ASSERT_FALSE (res); + + int count = 0; + mtrie.match (test_name, getlen (test_name), mtrie_count, &count); + TEST_ASSERT_EQUAL_INT (0, count); +} + int main (void) { setup_test_environment (); @@ -155,6 +170,7 @@ int main (void) RUN_TEST (test_add_rm_single_entry_match_exact); RUN_TEST (test_add_two_entries_match_prefix_and_exact); RUN_TEST (test_add_two_entries_with_same_name_match_exact); + RUN_TEST (test_rm_empty); return UNITY_END (); }