summaryrefslogtreecommitdiff
path: root/gtk/fnmatch.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-06-03 23:33:33 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-06-03 23:58:50 -0400
commit31407d0a4cc86b2507bc50684439b14e97b35e5e (patch)
tree710902cb51672511a49878ccc5f7b9eb88c3b817 /gtk/fnmatch.c
parentbb53cf53e7c683c667a9e47324360d2414fcf0bc (diff)
downloadgtk+-31407d0a4cc86b2507bc50684439b14e97b35e5e.tar.gz
Move fnmatch testcases to the testsuite
We have a well-working way to test internal apis now, lets use it for these tests.
Diffstat (limited to 'gtk/fnmatch.c')
-rw-r--r--gtk/fnmatch.c106
1 files changed, 0 insertions, 106 deletions
diff --git a/gtk/fnmatch.c b/gtk/fnmatch.c
index ba661afbbe..0ad1cd8992 100644
--- a/gtk/fnmatch.c
+++ b/gtk/fnmatch.c
@@ -253,109 +253,3 @@ _gtk_fnmatch (const char *pattern,
{
return gtk_fnmatch_intern (pattern, string, TRUE, no_leading_period, casefold);
}
-
-#undef FNMATCH_TEST_CASES
-#ifdef FNMATCH_TEST_CASES
-
-#define TEST(pat, str, no_leading_period, result) \
- g_assert (_gtk_fnmatch ((pat), (str), (no_leading_period)) == result)
-
-int main (int argc, char **argv)
-{
- TEST ("[a-]", "-", TRUE, TRUE);
-
- TEST ("a", "a", TRUE, TRUE);
- TEST ("a", "b", TRUE, FALSE);
-
- /* Test what ? matches */
- TEST ("?", "a", TRUE, TRUE);
- TEST ("?", ".", TRUE, FALSE);
- TEST ("a?", "a.", TRUE, TRUE);
- TEST ("a/?", "a/b", TRUE, TRUE);
- TEST ("a/?", "a/.", TRUE, FALSE);
- TEST ("?", "/", TRUE, FALSE);
-
- /* Test what * matches */
- TEST ("*", "a", TRUE, TRUE);
- TEST ("*", ".", TRUE, FALSE);
- TEST ("a*", "a.", TRUE, TRUE);
- TEST ("a/*", "a/b", TRUE, TRUE);
- TEST ("a/*", "a/.", TRUE, FALSE);
- TEST ("*", "/", TRUE, FALSE);
-
- /* Range tests */
- TEST ("[ab]", "a", TRUE, TRUE);
- TEST ("[ab]", "c", TRUE, FALSE);
- TEST ("[^ab]", "a", TRUE, FALSE);
- TEST ("[!ab]", "a", TRUE, FALSE);
- TEST ("[^ab]", "c", TRUE, TRUE);
- TEST ("[!ab]", "c", TRUE, TRUE);
- TEST ("[a-c]", "b", TRUE, TRUE);
- TEST ("[a-c]", "d", TRUE, FALSE);
- TEST ("[a-]", "-", TRUE, TRUE);
- TEST ("[]]", "]", TRUE, TRUE);
- TEST ("[^]]", "a", TRUE, TRUE);
- TEST ("[!]]", "a", TRUE, TRUE);
-
- /* Various unclosed ranges */
- TEST ("[ab", "a", TRUE, FALSE);
- TEST ("[a-", "a", TRUE, FALSE);
- TEST ("[ab", "c", TRUE, FALSE);
- TEST ("[a-", "c", TRUE, FALSE);
- TEST ("[^]", "a", TRUE, FALSE);
-
- /* Ranges and special no-wildcard matches */
- TEST ("[.]", ".", TRUE, FALSE);
- TEST ("a[.]", "a.", TRUE, TRUE);
- TEST ("a/[.]", "a/.", TRUE, FALSE);
- TEST ("[/]", "/", TRUE, FALSE);
- TEST ("[^/]", "a", TRUE, TRUE);
-
- /* Basic tests of * (and combinations of * and ?) */
- TEST ("a*b", "ab", TRUE, TRUE);
- TEST ("a*b", "axb", TRUE, TRUE);
- TEST ("a*b", "axxb", TRUE, TRUE);
- TEST ("a**b", "ab", TRUE, TRUE);
- TEST ("a**b", "axb", TRUE, TRUE);
- TEST ("a**b", "axxb", TRUE, TRUE);
- TEST ("a*?*b", "ab", TRUE, FALSE);
- TEST ("a*?*b", "axb", TRUE, TRUE);
- TEST ("a*?*b", "axxb", TRUE, TRUE);
-
- /* Test of *[range] */
- TEST ("a*[cd]", "ac", TRUE, TRUE);
- TEST ("a*[cd]", "axc", TRUE, TRUE);
- TEST ("a*[cd]", "axx", TRUE, FALSE);
-
- TEST ("a/[.]", "a/.", TRUE, FALSE);
- TEST ("a*[.]", "a/.", TRUE, FALSE);
-
- /* Test of UTF-8 */
-
- TEST ("ä", "ä", TRUE, TRUE); /* TEST ("ä", "ä", TRUE); */
- TEST ("?", "ä", TRUE, TRUE); /* TEST ("?", "ä", TRUE); */
- TEST ("*ö", "äö", TRUE, TRUE); /* TEST ("*ö", "äö", TRUE); */
- TEST ("*ö", "ääö", TRUE, TRUE); /* TEST ("*ö", "ääö", TRUE); */
- TEST ("[ä]", "ä", TRUE, TRUE); /* TEST ("[ä]", "ä", TRUE); */
- TEST ("[ä-ö]", "é", TRUE, TRUE); /* TEST ("[ä-ö]", "é", TRUE); */
- TEST ("[ä-ö]", "a", TRUE, FALSE); /* TEST ("[ä-ö]", "a", FALSE); */
-
-#ifdef DO_ESCAPE
- /* Tests of escaping */
- TEST ("\\\\", "\\", TRUE, TRUE);
- TEST ("\\?", "?", TRUE, TRUE);
- TEST ("\\?", "a", TRUE, FALSE);
- TEST ("\\*", "*", TRUE, TRUE);
- TEST ("\\*", "a", TRUE, FALSE);
- TEST ("\\[a-b]", "[a-b]", TRUE, TRUE);
- TEST ("[\\\\]", "\\", TRUE, TRUE);
- TEST ("[\\^a]", "a", TRUE, TRUE);
- TEST ("[a\\-c]", "b", TRUE, FALSE);
- TEST ("[a\\-c]", "-", TRUE, TRUE);
- TEST ("[a\\]", "a", TRUE, FALSE);
-#endif /* DO_ESCAPE */
-
- return 0;
-}
-
-#endif /* FNMATCH_TEST_CASES */