Simplify and add tests for ifind

This commit is contained in:
ridiculousfish
2018-10-21 15:53:58 -07:00
parent fcd4a44b98
commit ac241b7132
2 changed files with 21 additions and 21 deletions

View File

@@ -1731,6 +1731,17 @@ static void test_fuzzy_match() {
err(L"test_fuzzy_match failed on line %ld", __LINE__);
}
static void test_ifind() {
say(L"Testing ifind");
do_test(ifind(std::string{"alpha"}, std::string{"alpha"}) == 0);
do_test(ifind(wcstring{L"alphab"}, wcstring{L"alpha"}) == 0);
do_test(ifind(std::string{"alpha"}, std::string{"balpha"}) == std::string::npos);
do_test(ifind(std::string{"balpha"}, std::string{"alpha"}) == 1);
do_test(ifind(std::string{"alphab"}, std::string{"balpha"}) == std::string::npos);
do_test(ifind(std::string{"balpha"}, std::string{"lPh"}) == 2);
do_test(ifind(std::string{"balpha"}, std::string{"Plh"}) == std::string::npos);
}
static void test_abbreviations() {
say(L"Testing abbreviations");
env_push(true);
@@ -4786,6 +4797,7 @@ int main(int argc, char **argv) {
if (should_test_function("lru")) test_lru();
if (should_test_function("expand")) test_expand();
if (should_test_function("fuzzy_match")) test_fuzzy_match();
if (should_test_function("ifind")) test_ifind();
if (should_test_function("abbreviations")) test_abbreviations();
if (should_test_function("test")) test_test();
if (should_test_function("path")) test_path();