diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/Makefile.inc | 4 | ||||
-rw-r--r-- | tests/unit/curlcheck.h | 50 | ||||
-rw-r--r-- | tests/unit/unit1300.c | 25 | ||||
-rw-r--r-- | tests/unit/unit1301.c | 21 | ||||
-rw-r--r-- | tests/unit/unit1302.c | 21 | ||||
-rw-r--r-- | tests/unit/unit1303.c | 21 | ||||
-rw-r--r-- | tests/unit/unit1304.c | 21 | ||||
-rw-r--r-- | tests/unit/unit1305.c | 146 | ||||
-rw-r--r-- | tests/unit/unit1307.c | 233 |
9 files changed, 536 insertions, 6 deletions
diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc index 6dd7a4165..aef687113 100644 --- a/tests/unit/Makefile.inc +++ b/tests/unit/Makefile.inc @@ -3,10 +3,12 @@ UNITFILES = curlcheck.h # These are all unit test programs -noinst_PROGRAMS = unit1300 unit1301 unit1302 unit1303 unit1304 +noinst_PROGRAMS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 unit1307 unit1300_SOURCES = unit1300.c $(UNITFILES) unit1301_SOURCES = unit1301.c $(UNITFILES) 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/curlcheck.h b/tests/unit/curlcheck.h index 9d738430c..4b4d32c8d 100644 --- a/tests/unit/curlcheck.h +++ b/tests/unit/curlcheck.h @@ -1,14 +1,27 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ #include "test.h" +/* The fail macros mark the current test step as failed, and continue */ #define fail_if(expr, msg) \ if(expr) { \ fprintf(stderr, "%s:%d Assertion '%s' met: %s\n" , \ @@ -39,18 +52,45 @@ } while(0) +/* The abort macros mark the current test step as failed, and exit the test */ +#define abort_if(expr, msg) \ + if(expr) { \ + fprintf(stderr, "%s:%d Abort assertion '%s' met: %s\n" , \ + __FILE__, __LINE__, #expr, msg); \ + unitfail++; \ + goto unit_test_abort; \ + } + +#define abort_unless(expr, msg) \ + if(!(expr)) { \ + fprintf(stderr, "%s:%d Abort assertion '%s' failed: %s\n", \ + __FILE__, __LINE__, #expr, msg); \ + unitfail++; \ + goto unit_test_abort; \ + } + +#define abort_test(msg) do { \ + fprintf(stderr, "%s:%d test aborted: '%s'\n", \ + __FILE__, __LINE__, msg); \ + unitfail++; \ + goto unit_test_abort; \ + } while(0) + + extern int unitfail; #define UNITTEST_START \ - int test(char *unused) \ + int test(char *arg) \ { \ - (void)unused; \ + (void)arg; \ if (unit_setup()) { \ fail("unit_setup() failure"); \ } else { #define UNITTEST_STOP \ + goto unit_test_abort; /* avoid warning */ \ +unit_test_abort: \ unit_stop(); \ } \ return unitfail; \ diff --git a/tests/unit/unit1300.c b/tests/unit/unit1300.c index 92207011e..f4f5f2a54 100644 --- a/tests/unit/unit1300.c +++ b/tests/unit/unit1300.c @@ -1,3 +1,24 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ #include <stdlib.h> #include "curl_config.h" #include "setup.h" @@ -128,6 +149,7 @@ UNITTEST_START */ head=llist->head; + abort_unless(head, "llist->head is NULL"); element_next = head->next; llist_size = Curl_llist_count(llist); @@ -137,6 +159,7 @@ UNITTEST_START "llist size not decremented as expected"); fail_unless(llist->head == element_next, "llist new head not modified properly"); + abort_unless(llist->head, "llist->head is NULL"); fail_unless(llist->head->prev == NULL, "new head previous not set to null"); @@ -153,11 +176,13 @@ UNITTEST_START Curl_llist_insert_next(llist, llist->head, &unusedData_case3); llist_size = Curl_llist_count(llist); to_remove = llist->head->next; + abort_unless(to_remove, "to_remove is NULL"); element_next = to_remove->next; element_prev = to_remove->prev; Curl_llist_remove(llist, to_remove, NULL); fail_unless(element_prev->next == element_next, "element previous->next is not being adjusted"); + abort_unless(element_next, "element_next is NULL"); fail_unless(element_next->prev == element_prev, "element next->previous is not being adjusted"); diff --git a/tests/unit/unit1301.c b/tests/unit/unit1301.c index 7de6f069a..95f4b6aab 100644 --- a/tests/unit/unit1301.c +++ b/tests/unit/unit1301.c @@ -1,3 +1,24 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ #include <stdlib.h> #include "curl_config.h" #include "setup.h" diff --git a/tests/unit/unit1302.c b/tests/unit/unit1302.c index 1a6bf4e54..bc3651627 100644 --- a/tests/unit/unit1302.c +++ b/tests/unit/unit1302.c @@ -1,3 +1,24 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ #include <stdlib.h> #include "curl_config.h" #include "setup.h" diff --git a/tests/unit/unit1303.c b/tests/unit/unit1303.c index cabee85c2..2b5669d28 100644 --- a/tests/unit/unit1303.c +++ b/tests/unit/unit1303.c @@ -1,3 +1,24 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ #include <stdlib.h> #include "curl_config.h" #include "setup.h" diff --git a/tests/unit/unit1304.c b/tests/unit/unit1304.c index 34a54e9bc..8b3132edc 100644 --- a/tests/unit/unit1304.c +++ b/tests/unit/unit1304.c @@ -1,3 +1,24 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ #include <stdlib.h> #include "curl_config.h" #include "setup.h" diff --git a/tests/unit/unit1305.c b/tests/unit/unit1305.c new file mode 100644 index 000000000..02fa682a8 --- /dev/null +++ b/tests/unit/unit1305.c @@ -0,0 +1,146 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +#include "test.h" + +#ifdef HAVE_SYS_SOCKET_H +# include <sys/socket.h> +#endif +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif +#ifdef HAVE_NETDB_H +# include <netdb.h> +#endif +#ifdef HAVE_ARPA_INET_H +# include <arpa/inet.h> +#endif + +#define ENABLE_CURLX_PRINTF +#include "curlx.h" + +#include "hash.h" +#include "hostip.h" +#include "curlcheck.h" + +#include "curl_memory.h" +#include "memdebug.h" /* LAST include file */ + +static struct SessionHandle *data; +static struct curl_hash *hp; +static char *data_key; +static struct Curl_dns_entry *data_node; + +static CURLcode unit_setup( void ) +{ + data = curl_easy_init(); + if (!data) + return CURLE_OUT_OF_MEMORY; + + hp = Curl_mk_dnscache(); + if(!hp) { + curl_easy_cleanup(data); + curl_global_cleanup(); + return CURLE_OUT_OF_MEMORY; + } + return CURLE_OK; +} + +static void unit_stop( void ) +{ + if (data_node) { + Curl_freeaddrinfo(data_node->addr); + free(data_node); + } + if (data_key) + free(data_key); + + Curl_hash_destroy(hp); + + curl_easy_cleanup(data); + curl_global_cleanup(); +} + +static Curl_addrinfo *fake_ai(void) +{ + static Curl_addrinfo *ai; + int ss_size; + + ss_size = sizeof (struct sockaddr_in); + + if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL) + return NULL; + + if((ai->ai_canonname = strdup("dummy")) == NULL) { + free(ai); + return NULL; + } + + if((ai->ai_addr = calloc(1, ss_size)) == NULL) { + free(ai->ai_canonname); + free(ai); + return NULL; + } + + ai->ai_family = AF_INET; + ai->ai_addrlen = ss_size; + + return ai; +} + +static CURLcode create_node(void) +{ + data_key = aprintf("%s:%d", "dummy", 0); + if (!data_key) + return CURLE_OUT_OF_MEMORY; + + data_node = calloc(1, sizeof(struct Curl_dns_entry)); + if (!data_node) + return CURLE_OUT_OF_MEMORY; + + data_node->addr = fake_ai(); + if (!data_node->addr) + return CURLE_OUT_OF_MEMORY; + + return CURLE_OK; +} + + +UNITTEST_START + + struct Curl_dns_entry *nodep; + size_t key_len; + + /* Test 1305 exits without adding anything to the hash */ + if (strcmp(arg, "1305") != 0) { + CURLcode rc = create_node(); + abort_unless(rc == CURLE_OK, "data node creation failed"); + key_len = strlen(data_key); + + nodep = Curl_hash_add(hp, data_key, key_len+1, data_node); + abort_unless(nodep, "insertion into hash failed"); + /* Freeing will now be done by Curl_hash_destroy */ + data_node = NULL; + + /* To do: test retrieval, deletion, edge conditions */ + } + +UNITTEST_STOP diff --git a/tests/unit/unit1307.c b/tests/unit/unit1307.c new file mode 100644 index 000000000..983237e48 --- /dev/null +++ b/tests/unit/unit1307.c @@ -0,0 +1,233 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +#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 |