Files
profanity/tests/unittests/tools/test_autocomplete.h
Michael Vetter e9c6b3b3d8 feat(tools): support UTF-8 characters in autocompletion
Autocompletion failed for nicknames using non Latin scripts. We used
`g_str_to_ascii`, which replaces characters it cannot transliterate with
'?', leading search failures and false matches between different
scripts.

Now we do:
Use `g_utf8_casefold` for case-insensitive UTF-8 comparison. This
ensures that like 'Σ' correctly match 'σ' across all Unicode scripts,
providing correct results for non English nicknames.

If we don't fine anything typing a base ASCII character matches an
accented one (typing `e` matches `è`). This pass uses `g_str_to_ascii`
followed by `g_ascii_strdown` for comparison. It is now restricted to
run if the search string itself is valid ASCII, preventing the
"everything matches '?'" bug in non Latin scripts.

Autocomplete items are sorted using `strcmp`. `g_utf8_collate` provides
linguistical ordering for a specific language. But its behavior is
locale dependent and undefined when comparing strings from different
scripts. `strcmp` does byte-wise ordering that correctly follows Unicode
code order for UTF-8 strings.
2026-03-19 08:41:50 +01:00

29 lines
1.6 KiB
C

#ifndef TESTS_TEST_AUTOCOMPLETE_H
#define TESTS_TEST_AUTOCOMPLETE_H
void autocomplete_complete__returns__null_when_empty(void** state);
void autocomplete_reset__updates__after_create(void** state);
void autocomplete_complete__returns__null_after_create(void** state);
void autocomplete_create_list__returns__null_after_create(void** state);
void autocomplete_add__updates__one_and_complete(void** state);
void autocomplete_complete__returns__first_of_two(void** state);
void autocomplete_complete__returns__second_of_two(void** state);
void autocomplete_add__updates__two_elements(void** state);
void autocomplete_add__updates__only_once_for_same_value(void** state);
void autocomplete_add__updates__existing_value(void** state);
void autocomplete_complete__returns__accented_with_accented(void** state);
void autocomplete_complete__returns__accented_with_base(void** state);
void autocomplete_complete__returns__both_with_accented(void** state);
void autocomplete_complete__returns__both_with_base(void** state);
void autocomplete_complete__is__case_insensitive(void** state);
void autocomplete_complete__returns__previous(void** state);
void autocomplete_complete__returns__greek(void** state);
void autocomplete_complete__returns__greek_false_match(void** state);
void autocomplete_complete__returns__greek_case_insensitive(void** state);
void autocomplete_complete__returns__russian(void** state);
void autocomplete_complete__returns__chinese(void** state);
void autocomplete_complete__returns__transliterated(void** state);
void autocomplete_complete__returns__regular_ascii(void** state);
#endif