Skip to content

Commit

Permalink
Fix wildcard_tree equals test
Browse files Browse the repository at this point in the history
  • Loading branch information
ramon-bernardo committed Sep 6, 2024
1 parent 7b03a82 commit 836bca6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/tests/test_wildcard_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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");
}
Expand All @@ -52,14 +58,18 @@ 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");

root.remove("test");

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)
Expand All @@ -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");
}

0 comments on commit 836bca6

Please sign in to comment.