From 836bca6f82f4a1b44cdf3b0f04625621462fa6bd Mon Sep 17 00:00:00 2001 From: ramon-bernardo Date: Thu, 5 Sep 2024 23:22:38 -0300 Subject: [PATCH] Fix wildcard_tree equals test --- src/tests/test_wildcard_tree.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/tests/test_wildcard_tree.cpp b/src/tests/test_wildcard_tree.cpp index 4c2913cbd7..ea8b8bbd45 100644 --- a/src/tests/test_wildcard_tree.cpp +++ b/src/tests/test_wildcard_tree.cpp @@ -12,10 +12,14 @@ BOOST_AUTO_TEST_CASE(test_wildcard_tree_single_words) root.add("test"); - BOOST_CHECK_EQUAL(root.search("tes").first, WildcardTreeNode::NotFound); + BOOST_CHECK_EQUAL(root.search("tes").first, WildcardTreeNode::Found); + BOOST_CHECK_EQUAL(root.search("tes").second, "test"); + BOOST_CHECK_EQUAL(root.search("test").first, WildcardTreeNode::Found); BOOST_CHECK_EQUAL(root.search("test").second, "test"); + BOOST_CHECK_EQUAL(root.search("testing").first, WildcardTreeNode::NotFound); + BOOST_CHECK_EQUAL(root.search("testing").second, ""); } BOOST_AUTO_TEST_CASE(test_wildcard_tree_ambiguity) @@ -26,6 +30,8 @@ BOOST_AUTO_TEST_CASE(test_wildcard_tree_ambiguity) root.add("te"); BOOST_CHECK_EQUAL(root.search("te").first, WildcardTreeNode::Ambiguous); + BOOST_CHECK_EQUAL(root.search("te").second, ""); + BOOST_CHECK_EQUAL(root.search("test").first, WildcardTreeNode::Found); BOOST_CHECK_EQUAL(root.search("test").second, "test"); } @@ -52,6 +58,8 @@ BOOST_AUTO_TEST_CASE(test_wildcard_tree_partial_search) root.add("te"); BOOST_CHECK_EQUAL(root.search("te").first, WildcardTreeNode::Ambiguous); + BOOST_CHECK_EQUAL(root.search("te").second, ""); + BOOST_CHECK_EQUAL(root.search("test").first, WildcardTreeNode::Found); BOOST_CHECK_EQUAL(root.search("test").second, "test"); @@ -59,7 +67,9 @@ BOOST_AUTO_TEST_CASE(test_wildcard_tree_partial_search) BOOST_CHECK_EQUAL(root.search("te").first, WildcardTreeNode::Found); BOOST_CHECK_EQUAL(root.search("te").second, "te"); + BOOST_CHECK_EQUAL(root.search("test").first, WildcardTreeNode::NotFound); + BOOST_CHECK_EQUAL(root.search("test").second, ""); } BOOST_AUTO_TEST_CASE(test_wildcard_tree_search_after_remove) @@ -71,6 +81,8 @@ BOOST_AUTO_TEST_CASE(test_wildcard_tree_search_after_remove) root.remove("test"); BOOST_CHECK_EQUAL(root.search("test").first, WildcardTreeNode::NotFound); + BOOST_CHECK_EQUAL(root.search("test").second, ""); + BOOST_CHECK_EQUAL(root.search("testing").first, WildcardTreeNode::Found); BOOST_CHECK_EQUAL(root.search("testing").second, "testing"); }