diff options
author | Phil Jones <philj56@gmail.com> | 2022-10-18 19:33:47 +0100 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-10-18 19:53:06 +0100 |
commit | 340692299ed834f962b83b1bc0eb6f49471ca556 (patch) | |
tree | f0a1c9160397b22a662e6399e085336de3396a73 /test/utf8.c | |
parent | 5482f0be746a98bdd6b2c54183b54dd2ff2a0192 (diff) |
Add beginnings of test framework.
Just contains a couple of very simple UTF-8 tests for now.
Diffstat (limited to 'test/utf8.c')
-rw-r--r-- | test/utf8.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/utf8.c b/test/utf8.c new file mode 100644 index 0000000..494e75b --- /dev/null +++ b/test/utf8.c @@ -0,0 +1,67 @@ +#include <assert.h> +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "fuzzy_match.h" +#include "tap.h" +#include "utf8.h" + +void is_simple_match(const char *pattern, const char *str, const char *message) +{ + int32_t res = fuzzy_match_simple_words(pattern, str); + tap_isnt(res, INT32_MIN, message); +} + +void isnt_simple_match(const char *pattern, const char *str, const char *message) +{ + int32_t res = fuzzy_match_simple_words(pattern, str); + tap_is(res, INT32_MIN, message); +} + +void is_fuzzy_match(const char *pattern, const char *str, const char *message) +{ + int32_t res = fuzzy_match_words(pattern, str); + tap_isnt(res, INT32_MIN, message); +} + +void isnt_fuzzy_match(const char *pattern, const char *str, const char *message) +{ + int32_t res = fuzzy_match_words(pattern, str); + tap_is(res, INT32_MIN, message); +} + +void is_match(const char *pattern, const char *str, const char *message) +{ + is_simple_match(pattern, str, message); + is_fuzzy_match(pattern, str, message); +} + +void isnt_match(const char *pattern, const char *str, const char *message) +{ + isnt_simple_match(pattern, str, message); + isnt_fuzzy_match(pattern, str, message); +} + +int main(int argc, char *argv[]) +{ + setlocale(LC_ALL, ""); + + tap_version(14); + + /* Case insensitivity. */ + is_match("o", "O", "Single Latin character, different case"); + is_match("д", "Д", "Single Cyrillic character, different case"); + is_match("ξ", "Ξ", "Single Greek character, different case"); + is_match("o", "ọ", "Single character with decomposed diacritic"); + + /* Combining diacritics. */ + isnt_match("o", "ọ", "Single character with composed diacritic"); + isnt_simple_match("ạ", "aọ", "Decomposed diacritics, character mismatch"); + tap_todo("Needs composed character comparison"); + isnt_fuzzy_match("ạ", "aọ", "Decomposed diacritics, character mismatch"); + + tap_plan(); + + return EXIT_SUCCESS; +} |