Correct check and add a basic test for fuzzy_match_substring_case_insensitive

This commit is contained in:
ridiculousfish 2018-10-21 12:02:38 -07:00
parent 5efa18da15
commit fcd4a44b98
2 changed files with 3 additions and 1 deletions

View File

@ -1848,7 +1848,7 @@ string_fuzzy_match_t string_fuzzy_match_string(const wcstring &string,
assert(match_against.size() >= string.size());
result.match_distance_first = match_against.size() - string.size();
result.match_distance_second = location; // prefer earlier matches
} else if (limit_type >= fuzzy_match_substring &&
} else if (limit_type >= fuzzy_match_substring_case_insensitive &&
(location = ifind(match_against, string)) != wcstring::npos) {
// A case-insensitive version of the string is in the match against.
result.type = fuzzy_match_substring_case_insensitive;

View File

@ -1723,6 +1723,8 @@ static void test_fuzzy_match() {
err(L"test_fuzzy_match failed on line %ld", __LINE__);
if (string_fuzzy_match_string(L"LPH", L"ALPHA!").type != fuzzy_match_substring)
err(L"test_fuzzy_match failed on line %ld", __LINE__);
if (string_fuzzy_match_string(L"lPh", L"ALPHA!").type != fuzzy_match_substring_case_insensitive)
err(L"test_fuzzy_match failed on line %ld", __LINE__);
if (string_fuzzy_match_string(L"AA", L"ALPHA!").type != fuzzy_match_subsequence_insertions_only)
err(L"test_fuzzy_match failed on line %ld", __LINE__);
if (string_fuzzy_match_string(L"BB", L"ALPHA!").type != fuzzy_match_none)