From c60a6153be81956b8bd9fcec46fc12ee3b7ca38a Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 4 Mar 2011 15:56:40 -0800 Subject: Moved test 577 into the unit test framework as test 1307 --- tests/data/Makefile.am | 4 +- tests/data/test1307 | 27 +++++ tests/data/test577 | 43 -------- tests/libtest/Makefile.inc | 4 +- tests/libtest/lib577.c | 255 --------------------------------------------- tests/unit/Makefile.inc | 3 +- tests/unit/unit1307.c | 221 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 253 insertions(+), 304 deletions(-) create mode 100644 tests/data/test1307 delete mode 100644 tests/data/test577 delete mode 100644 tests/libtest/lib577.c create mode 100644 tests/unit/unit1307.c (limited to 'tests') diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index c925d0ee0..aa060ed1a 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -60,7 +60,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \ test1072 test1073 test1074 test1075 test1076 test1077 test1078 test1079 \ test1080 test1081 test1082 test1083 test1084 test1085 test633 test634 \ test635 test636 test637 test1086 test1087 test1088 \ - test574 test575 test576 test577 test1113 test1114 test1089 test1090 \ + test574 test575 test576 test1113 test1114 test1089 test1090 \ test1091 test1092 test1093 test1094 test1095 test1096 test1097 test560 \ test561 test1098 test1099 test562 test563 test1100 test564 test1101 \ test1102 test1103 test1104 test299 test310 test311 test312 test1105 \ @@ -70,7 +70,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \ test313 test1115 test578 test579 test1116 test1200 test1201 test1202 \ test1203 test1117 test1118 test1119 test1120 test1300 test1301 test1302 \ test1303 test320 test321 test322 test323 test324 test1121 test581 test580 \ - test1304 test1305 test1306 + test1304 test1305 test1306 test1307 filecheck: @mkdir test-place; \ diff --git a/tests/data/test1307 b/tests/data/test1307 new file mode 100644 index 000000000..82ed3c07f --- /dev/null +++ b/tests/data/test1307 @@ -0,0 +1,27 @@ + + + + +unittest +wildcardmatch + + + +# +# Client-side + + +none + + +unittest + + +internal Curl_fnmatch() testing + + +unit1307 + + + + diff --git a/tests/data/test577 b/tests/data/test577 deleted file mode 100644 index 7a69ead20..000000000 --- a/tests/data/test577 +++ /dev/null @@ -1,43 +0,0 @@ - - - -wildcardmatch - - -# -# Server-side - - - -# Client-side - - -none - -# tool is what to use instead of 'curl' - -lib577 - -# precheck is a command line to run before the test, -# to see if we can execute the test or not - -./libtest/lib577 check - - - -Curl_fnmatch() testing - - -nothing - - - -# -# Verify data after the test has been "shot" - - -=========================== -=========================== - - - diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 322feeac4..5fb9fad6f 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -8,7 +8,7 @@ SUPPORTFILES = first.c test.h noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \ lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516 \ lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526 lib527 \ - lib574 lib575 lib576 lib577 lib578 lib579 \ + lib574 lib575 lib576 lib578 lib579 \ lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \ lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \ lib539 lib557 lib560 lib562 lib564 lib565 lib566 lib567 \ @@ -130,8 +130,6 @@ lib575_SOURCES = lib575.c $(SUPPORTFILES) lib576_SOURCES = lib576.c $(SUPPORTFILES) -lib577_SOURCES = lib577.c $(SUPPORTFILES) - lib562_SOURCES = lib562.c $(SUPPORTFILES) lib564_SOURCES = lib564.c $(SUPPORTFILES) $(TESTUTIL) diff --git a/tests/libtest/lib577.c b/tests/libtest/lib577.c deleted file mode 100644 index bd52c6251..000000000 --- a/tests/libtest/lib577.c +++ /dev/null @@ -1,255 +0,0 @@ -/***************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - */ - -#include "test.h" - -/* - * This hacky test bypasses the library external API, - * using internal only libcurl functions. So don't be - * surprised if we cannot run it when the library has - * been built with hidden symbols, exporting only the - * ones in the public API. - */ - -#if defined(CURL_HIDDEN_SYMBOLS) -# define SKIP_TEST 1 -#elif defined(WIN32) && !defined(CURL_STATICLIB) -# define SKIP_TEST 1 -#else -# undef SKIP_TEST -#endif - - -#if !defined(SKIP_TEST) - -#include "memdebug.h" - -#include "curl_fnmatch.h" - -#define MATCH CURL_FNMATCH_MATCH -#define NOMATCH CURL_FNMATCH_NOMATCH -#define RE_ERR CURL_FNMATCH_FAIL - -#define MAX_PATTERN_L 100 -#define MAX_STRING_L 100 - -struct testcase { - char pattern[MAX_PATTERN_L]; - char string[MAX_STRING_L]; - int result; -}; - -static const struct testcase tests[] = { - /* brackets syntax */ - { "\\[", "[", MATCH }, - { "[", "[", RE_ERR }, - { "[]", "[]", RE_ERR }, - { "[][]", "[", MATCH }, - { "[][]", "]", MATCH }, - { "[[]", "[", MATCH }, - { "[[[]", "[", MATCH }, - { "[[[[]", "[", MATCH }, - { "[[[[]", "[", MATCH }, - - { "[][[]", "]", MATCH }, - { "[][[[]", "[", MATCH }, - { "[[]", "]", NOMATCH }, - - { "[a-z]", "a", MATCH }, - { "[a-z]", "A", NOMATCH }, - { "?[a-z]", "?Z", NOMATCH }, - { "[A-Z]", "C", MATCH }, - { "[A-Z]", "c", NOMATCH }, - { "[0-9]", "7", MATCH }, - { "[7-8]", "7", MATCH }, - { "[7-]", "7", MATCH }, - { "[7-]", "-", MATCH }, - { "[7-]", "[", NOMATCH }, - { "[a-bA-F]", "F", MATCH }, - { "[a-bA-B9]", "9", MATCH }, - { "[a-bA-B98]", "8", MATCH }, - { "[a-bA-B98]", "C", NOMATCH }, - { "[a-bA-Z9]", "F", MATCH }, - { "[a-bA-Z9]ero*", "Zero chance.", MATCH }, - { "S[a-][x]opho*", "Saxophone", MATCH }, - { "S[a-][x]opho*", "SaXophone", NOMATCH }, - { "S[a-][x]*.txt", "S-x.txt", MATCH }, - { "[\\a-\\b]", "a", MATCH }, - { "[\\a-\\b]", "b", MATCH }, - { "[?*[][?*[][?*[]", "?*[", MATCH }, - { "[][?*-]", "]", MATCH }, - { "[][?*-]", "[", MATCH }, - { "[][?*-]", "?", MATCH }, - { "[][?*-]", "*", MATCH }, - { "[][?*-]", "-", MATCH }, - { "[]?*-]", "-", MATCH }, - { "?/b/c", "a/b/c", MATCH }, - { "^_{}~", "^_{}~", MATCH }, - { "!#%+,-./01234567889", "!#%+,-./01234567889", MATCH }, - { "PQRSTUVWXYZ]abcdefg", "PQRSTUVWXYZ]abcdefg", MATCH }, - { ":;=@ABCDEFGHIJKLMNO", ":;=@ABCDEFGHIJKLMNO", MATCH }, - - /* negate */ - { "[!a]", "b", MATCH }, - { "[!a]", "a", NOMATCH }, - { "[^a]", "b", MATCH }, - { "[^a]", "a", NOMATCH }, - { "[^a-z0-9A-Z]", "a", NOMATCH }, - { "[^a-z0-9A-Z]", "-", MATCH }, - { "curl[!a-z]lib", "curl lib", MATCH }, - { "curl[! ]lib", "curl lib", NOMATCH }, - { "[! ][ ]", " ", NOMATCH }, - { "[! ][ ]", "a ", MATCH }, - { "*[^a].t?t", "a.txt", NOMATCH }, - { "*[^a].t?t", "ba.txt", NOMATCH }, - { "*[^a].t?t", "ab.txt", MATCH }, - { "[!?*[]", "?", NOMATCH }, - { "[!!]", "!", NOMATCH }, - { "[!!]", "x", MATCH }, - - { "[[:alpha:]]", "a", MATCH }, - { "[[:alpha:]]", "9", NOMATCH }, - { "[[:alnum:]]", "a", MATCH }, - { "[[:alnum:]]", "[", NOMATCH }, - { "[[:alnum:]]", "]", NOMATCH }, - { "[[:alnum:]]", "9", MATCH }, - { "[[:digit:]]", "9", MATCH }, - { "[[:xdigit:]]", "9", MATCH }, - { "[[:xdigit:]]", "F", MATCH }, - { "[[:xdigit:]]", "G", NOMATCH }, - { "[[:upper:]]", "U", MATCH }, - { "[[:upper:]]", "u", NOMATCH }, - { "[[:lower:]]", "l", MATCH }, - { "[[:lower:]]", "L", NOMATCH }, - { "[[:print:]]", "L", MATCH }, - { "[[:print:]]", {'\10'}, NOMATCH }, - { "[[:print:]]", {'\10'}, NOMATCH }, - { "[[:space:]]", " ", MATCH }, - { "[[:space:]]", "x", NOMATCH }, - { "[[:graph:]]", " ", NOMATCH }, - { "[[:graph:]]", "x", MATCH }, - { "[[:blank:]]", {'\t'}, MATCH }, - { "[[:blank:]]", {' '}, MATCH }, - { "[[:blank:]]", {'\r'}, NOMATCH }, - { "[^[:blank:]]", {'\t'}, NOMATCH }, - { "[^[:print:]]", {'\10'}, MATCH }, - { "[[:lower:]][[:lower:]]", "ll", MATCH }, - - { "Curl[[:blank:]];-)", "Curl ;-)", MATCH }, - { "*[[:blank:]]*", " ", MATCH }, - { "*[[:blank:]]*", "", NOMATCH }, - { "*[[:blank:]]*", "hi, im_Pavel", MATCH }, - - /* common using */ - { "filename.dat", "filename.dat", MATCH }, - { "*curl*", "lets use curl!!", MATCH }, - { "filename.txt", "filename.dat", NOMATCH }, - { "*.txt", "text.txt", MATCH }, - { "*.txt", "a.txt", MATCH }, - { "*.txt", ".txt", MATCH }, - { "*.txt", "txt", NOMATCH }, - { "??.txt", "99.txt", MATCH }, - { "??.txt", "a99.txt", NOMATCH }, - { "?.???", "a.txt", MATCH }, - { "*.???", "somefile.dat", MATCH }, - { "*.???", "photo.jpeg", NOMATCH }, - { ".*", ".htaccess", MATCH }, - { ".*", ".", MATCH }, - { ".*", "..", MATCH }, - - /* many stars => one star */ - { "**.txt", "text.txt", MATCH }, - { "***.txt", "t.txt", MATCH }, - { "****.txt", ".txt", MATCH }, - - /* empty string or pattern */ - { "", "", MATCH } , - { "", "hello", NOMATCH }, - { "file", "", NOMATCH }, - { "?", "", NOMATCH }, - { "*", "", MATCH }, - { "x", "", NOMATCH }, - - /* backslash */ - { "\\", "\\", RE_ERR }, - { "\\\\", "\\", MATCH }, - { "\\\\", "\\\\", NOMATCH }, - { "\\?", "?", MATCH }, - { "\\*", "*", MATCH }, - { "?.txt", "?.txt", MATCH }, - { "*.txt", "*.txt", MATCH }, - { "\\?.txt", "?.txt", MATCH }, - { "\\*.txt", "*.txt", MATCH }, - { "\\?.txt", "x.txt", NOMATCH }, - { "\\*.txt", "x.txt", NOMATCH }, - { "\\*\\\\.txt", "*\\.txt", MATCH }, - { "*\\**\\?*\\\\*", "cc*cc?cc\\cc*cc", MATCH }, - { "*\\**\\?*\\\\*", "cc*cc?cccc", NOMATCH }, - { "*\\**\\?*\\\\*", "cc*cc?cc\\cc*cc", MATCH }, - { "*\\?*\\**", "cc?c*c", MATCH }, - { "*\\?*\\**curl*", "cc?c*curl", MATCH }, - { "*\\?*\\**", "cc?cc", NOMATCH }, - { "\\\"\\$\\&\\'\\(\\)", "\"$&'()", MATCH }, - { "\\*\\?\\[\\\\\\`\\|", "*?[\\`|", MATCH }, - { "[\\a\\b]c", "ac", MATCH }, - { "[\\a\\b]c", "bc", MATCH }, - { "[\\a\\b]d", "bc", NOMATCH }, - { "[a-bA-B\\?]", "?", MATCH }, - { "cu[a-ab-b\\r]l", "curl", MATCH }, - { "[\\a-z]", "c", MATCH }, - - { "?*?*?.*?*", "abc.c", MATCH }, - { "?*?*?.*?*", "abcc", NOMATCH }, - { "?*?*?.*?*", "abc.", NOMATCH }, - { "?*?*?.*?*", "abc.c++", MATCH }, - { "?*?*?.*?*", "abcdef.c++", MATCH }, - { "?*?*?.?", "abcdef.c", MATCH }, - { "?*?*?.?", "abcdef.cd", NOMATCH }, - - { "Lindmätarv", "Lindmätarv", MATCH }, - - { "", "", MATCH } -}; - - -int test(char *URL) -{ - int testnum = sizeof(tests) / sizeof(struct testcase); - int i, rc; - (void)URL; /* not used */ - - if(!strcmp(URL, "check")) { - /* test harness script verifying if this test can run */ - return 0; /* sure, run this! */ - } - - printf("===========================\n"); - for(i = 0; i < testnum; i++) { - rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string); - if(rc != tests[i].result) { - printf("Curl_fnmatch(\"%s\", \"%s\") should return %d (returns %d)\n", - tests[i].pattern, tests[i].string, tests[i].result, rc); - } - } - printf("===========================\n"); - return 0; -} - -#else /* !defined(SKIP_TEST) */ - - -int test(char *URL) -{ - (void)URL; - fprintf(stdout, "libcurl built with hidden symbols"); - return 1; /* skip test */ -} - - -#endif /* !defined(SKIP_TEST) */ diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc index 537622d42..aef687113 100644 --- a/tests/unit/Makefile.inc +++ b/tests/unit/Makefile.inc @@ -3,7 +3,7 @@ UNITFILES = curlcheck.h # These are all unit test programs -noinst_PROGRAMS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 +noinst_PROGRAMS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 unit1307 unit1300_SOURCES = unit1300.c $(UNITFILES) unit1301_SOURCES = unit1301.c $(UNITFILES) @@ -11,3 +11,4 @@ unit1302_SOURCES = unit1302.c $(UNITFILES) unit1303_SOURCES = unit1303.c $(UNITFILES) unit1304_SOURCES = unit1304.c $(UNITFILES) unit1305_SOURCES = unit1305.c $(UNITFILES) +unit1307_SOURCES = unit1307.c $(UNITFILES) diff --git a/tests/unit/unit1307.c b/tests/unit/unit1307.c new file mode 100644 index 000000000..7acfbb4b9 --- /dev/null +++ b/tests/unit/unit1307.c @@ -0,0 +1,221 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + */ + +#include "curl_fnmatch.h" +#include "curlcheck.h" + +#define MATCH CURL_FNMATCH_MATCH +#define NOMATCH CURL_FNMATCH_NOMATCH +#define RE_ERR CURL_FNMATCH_FAIL + +#define MAX_PATTERN_L 100 +#define MAX_STRING_L 100 + +struct testcase { + char pattern[MAX_PATTERN_L]; + char string[MAX_STRING_L]; + int result; +}; + +static const struct testcase tests[] = { + /* brackets syntax */ + { "\\[", "[", MATCH }, + { "[", "[", RE_ERR }, + { "[]", "[]", RE_ERR }, + { "[][]", "[", MATCH }, + { "[][]", "]", MATCH }, + { "[[]", "[", MATCH }, + { "[[[]", "[", MATCH }, + { "[[[[]", "[", MATCH }, + { "[[[[]", "[", MATCH }, + + { "[][[]", "]", MATCH }, + { "[][[[]", "[", MATCH }, + { "[[]", "]", NOMATCH }, + + { "[a-z]", "a", MATCH }, + { "[a-z]", "A", NOMATCH }, + { "?[a-z]", "?Z", NOMATCH }, + { "[A-Z]", "C", MATCH }, + { "[A-Z]", "c", NOMATCH }, + { "[0-9]", "7", MATCH }, + { "[7-8]", "7", MATCH }, + { "[7-]", "7", MATCH }, + { "[7-]", "-", MATCH }, + { "[7-]", "[", NOMATCH }, + { "[a-bA-F]", "F", MATCH }, + { "[a-bA-B9]", "9", MATCH }, + { "[a-bA-B98]", "8", MATCH }, + { "[a-bA-B98]", "C", NOMATCH }, + { "[a-bA-Z9]", "F", MATCH }, + { "[a-bA-Z9]ero*", "Zero chance.", MATCH }, + { "S[a-][x]opho*", "Saxophone", MATCH }, + { "S[a-][x]opho*", "SaXophone", NOMATCH }, + { "S[a-][x]*.txt", "S-x.txt", MATCH }, + { "[\\a-\\b]", "a", MATCH }, + { "[\\a-\\b]", "b", MATCH }, + { "[?*[][?*[][?*[]", "?*[", MATCH }, + { "[][?*-]", "]", MATCH }, + { "[][?*-]", "[", MATCH }, + { "[][?*-]", "?", MATCH }, + { "[][?*-]", "*", MATCH }, + { "[][?*-]", "-", MATCH }, + { "[]?*-]", "-", MATCH }, + { "?/b/c", "a/b/c", MATCH }, + { "^_{}~", "^_{}~", MATCH }, + { "!#%+,-./01234567889", "!#%+,-./01234567889", MATCH }, + { "PQRSTUVWXYZ]abcdefg", "PQRSTUVWXYZ]abcdefg", MATCH }, + { ":;=@ABCDEFGHIJKLMNO", ":;=@ABCDEFGHIJKLMNO", MATCH }, + + /* negate */ + { "[!a]", "b", MATCH }, + { "[!a]", "a", NOMATCH }, + { "[^a]", "b", MATCH }, + { "[^a]", "a", NOMATCH }, + { "[^a-z0-9A-Z]", "a", NOMATCH }, + { "[^a-z0-9A-Z]", "-", MATCH }, + { "curl[!a-z]lib", "curl lib", MATCH }, + { "curl[! ]lib", "curl lib", NOMATCH }, + { "[! ][ ]", " ", NOMATCH }, + { "[! ][ ]", "a ", MATCH }, + { "*[^a].t?t", "a.txt", NOMATCH }, + { "*[^a].t?t", "ba.txt", NOMATCH }, + { "*[^a].t?t", "ab.txt", MATCH }, + { "[!?*[]", "?", NOMATCH }, + { "[!!]", "!", NOMATCH }, + { "[!!]", "x", MATCH }, + + { "[[:alpha:]]", "a", MATCH }, + { "[[:alpha:]]", "9", NOMATCH }, + { "[[:alnum:]]", "a", MATCH }, + { "[[:alnum:]]", "[", NOMATCH }, + { "[[:alnum:]]", "]", NOMATCH }, + { "[[:alnum:]]", "9", MATCH }, + { "[[:digit:]]", "9", MATCH }, + { "[[:xdigit:]]", "9", MATCH }, + { "[[:xdigit:]]", "F", MATCH }, + { "[[:xdigit:]]", "G", NOMATCH }, + { "[[:upper:]]", "U", MATCH }, + { "[[:upper:]]", "u", NOMATCH }, + { "[[:lower:]]", "l", MATCH }, + { "[[:lower:]]", "L", NOMATCH }, + { "[[:print:]]", "L", MATCH }, + { "[[:print:]]", {'\10'}, NOMATCH }, + { "[[:print:]]", {'\10'}, NOMATCH }, + { "[[:space:]]", " ", MATCH }, + { "[[:space:]]", "x", NOMATCH }, + { "[[:graph:]]", " ", NOMATCH }, + { "[[:graph:]]", "x", MATCH }, + { "[[:blank:]]", {'\t'}, MATCH }, + { "[[:blank:]]", {' '}, MATCH }, + { "[[:blank:]]", {'\r'}, NOMATCH }, + { "[^[:blank:]]", {'\t'}, NOMATCH }, + { "[^[:print:]]", {'\10'}, MATCH }, + { "[[:lower:]][[:lower:]]", "ll", MATCH }, + + { "Curl[[:blank:]];-)", "Curl ;-)", MATCH }, + { "*[[:blank:]]*", " ", MATCH }, + { "*[[:blank:]]*", "", NOMATCH }, + { "*[[:blank:]]*", "hi, im_Pavel", MATCH }, + + /* common using */ + { "filename.dat", "filename.dat", MATCH }, + { "*curl*", "lets use curl!!", MATCH }, + { "filename.txt", "filename.dat", NOMATCH }, + { "*.txt", "text.txt", MATCH }, + { "*.txt", "a.txt", MATCH }, + { "*.txt", ".txt", MATCH }, + { "*.txt", "txt", NOMATCH }, + { "??.txt", "99.txt", MATCH }, + { "??.txt", "a99.txt", NOMATCH }, + { "?.???", "a.txt", MATCH }, + { "*.???", "somefile.dat", MATCH }, + { "*.???", "photo.jpeg", NOMATCH }, + { ".*", ".htaccess", MATCH }, + { ".*", ".", MATCH }, + { ".*", "..", MATCH }, + + /* many stars => one star */ + { "**.txt", "text.txt", MATCH }, + { "***.txt", "t.txt", MATCH }, + { "****.txt", ".txt", MATCH }, + + /* empty string or pattern */ + { "", "", MATCH } , + { "", "hello", NOMATCH }, + { "file", "", NOMATCH }, + { "?", "", NOMATCH }, + { "*", "", MATCH }, + { "x", "", NOMATCH }, + + /* backslash */ + { "\\", "\\", RE_ERR }, + { "\\\\", "\\", MATCH }, + { "\\\\", "\\\\", NOMATCH }, + { "\\?", "?", MATCH }, + { "\\*", "*", MATCH }, + { "?.txt", "?.txt", MATCH }, + { "*.txt", "*.txt", MATCH }, + { "\\?.txt", "?.txt", MATCH }, + { "\\*.txt", "*.txt", MATCH }, + { "\\?.txt", "x.txt", NOMATCH }, + { "\\*.txt", "x.txt", NOMATCH }, + { "\\*\\\\.txt", "*\\.txt", MATCH }, + { "*\\**\\?*\\\\*", "cc*cc?cc\\cc*cc", MATCH }, + { "*\\**\\?*\\\\*", "cc*cc?cccc", NOMATCH }, + { "*\\**\\?*\\\\*", "cc*cc?cc\\cc*cc", MATCH }, + { "*\\?*\\**", "cc?c*c", MATCH }, + { "*\\?*\\**curl*", "cc?c*curl", MATCH }, + { "*\\?*\\**", "cc?cc", NOMATCH }, + { "\\\"\\$\\&\\'\\(\\)", "\"$&'()", MATCH }, + { "\\*\\?\\[\\\\\\`\\|", "*?[\\`|", MATCH }, + { "[\\a\\b]c", "ac", MATCH }, + { "[\\a\\b]c", "bc", MATCH }, + { "[\\a\\b]d", "bc", NOMATCH }, + { "[a-bA-B\\?]", "?", MATCH }, + { "cu[a-ab-b\\r]l", "curl", MATCH }, + { "[\\a-z]", "c", MATCH }, + + { "?*?*?.*?*", "abc.c", MATCH }, + { "?*?*?.*?*", "abcc", NOMATCH }, + { "?*?*?.*?*", "abc.", NOMATCH }, + { "?*?*?.*?*", "abc.c++", MATCH }, + { "?*?*?.*?*", "abcdef.c++", MATCH }, + { "?*?*?.?", "abcdef.c", MATCH }, + { "?*?*?.?", "abcdef.cd", NOMATCH }, + + { "Lindmätarv", "Lindmätarv", MATCH }, + + { "", "", MATCH } +}; + +static CURLcode unit_setup( void ) +{ + return CURLE_OK; +} + +static void unit_stop( void ) +{ +} + +UNITTEST_START + + int testnum = sizeof(tests) / sizeof(struct testcase); + int i, rc; + + for(i = 0; i < testnum; i++) { + rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string); + if(rc != tests[i].result) { + printf("Curl_fnmatch(\"%s\", \"%s\") should return %d (returns %d)\n", + tests[i].pattern, tests[i].string, tests[i].result, rc); + fail("pattern mismatch"); + } + } + +UNITTEST_STOP -- cgit v1.2.3