int main(void) { char *empty = (char *)""; wget_info_printf("%d\n", wget_base64_is_string("")); // base64.c wget_buffer_alloc(0); // buffer.c wget_buffer_printf((wget_buffer_t *)1, "%s", ""); // buffer_printf.c strlcpy((char *)"", "", 0); // strlcpy.c wget_css_parse_buffer((const char *)1, 0, NULL, NULL, NULL); // css.c wget_decompress_close(NULL); // decompressor.c wget_hashmap_create(0, 0, NULL, NULL); // hashmap.c wget_fdgetline(&empty, (size_t *)1, 0); // io.c wget_iri_parse("", NULL); // iri.c wget_list_free((wget_list_t **)1); // list.c wget_debug_write("", 0); // log.c wget_logger_set_file(NULL, ""); // logger.c wget_tcp_set_connect_timeout(NULL, 0); // net.c wget_netrc_deinit(NULL); // netrc.c wget_strdup(""); // mem.c // wget_popenf("r", "%s", ""); // pipe.c // wget_bsprintf(NULL, NULL, "%s", ""); // printf.c wget_ssl_set_config_int(0, 0); // ssl_[gnutls].c wget_stringmap_create(0); // stringmap.c if (wget_strcmp("", "")) {}; // utils.c wget_vector_set_destructor(NULL, NULL); // vector.c wget_malloc(1); // xalloc.c wget_xml_parse_buffer("", NULL, NULL, 0); // xml.c }
static void test_iri_parse(void) { const struct iri_test_data { const char *uri, *display, *scheme, *userinfo, *password, *host, *port, *path, *query, *fragment; } test_data[] = { { "1.2.3.4", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "1.2.3.4", NULL, NULL, NULL, NULL}, { "1.2.3.4:987", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "1.2.3.4", "987", NULL, NULL, NULL}, { "//example.com/thepath", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, "thepath", NULL, NULL}, // { "///thepath", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, NULL, NULL, "thepath", NULL, NULL}, { "example.com", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, NULL, NULL, NULL}, { "example.com:555", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", "555", NULL, NULL, NULL}, { "http://example.com", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, NULL, NULL, NULL}, { "http://example.com:", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, NULL, NULL, NULL}, { "http://example.com:/", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, "", NULL, NULL}, { "http://example.com:80/", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, "", NULL, NULL}, { "https://example.com", NULL, WGET_IRI_SCHEME_HTTPS, NULL, NULL, "example.com", NULL, NULL, NULL, NULL}, { "https://example.com:443", NULL, WGET_IRI_SCHEME_HTTPS, NULL, NULL, "example.com", NULL, NULL, NULL, NULL}, { "https://example.com:444", NULL, WGET_IRI_SCHEME_HTTPS, NULL, NULL, "example.com", "444", NULL, NULL, NULL}, { "http://example.com:80", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, NULL, NULL, NULL}, { "http://example.com:81", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", "81", NULL, NULL, NULL}, { "http://example.com/index.html", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, "index.html", NULL, NULL}, { "http://example.com/index.html?query#frag", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, "index.html", "query", "frag"}, { "http://example.com/index.html?query¶m#frag", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, "index.html", "query¶m", "frag"}, { "http://example.com/index.html?query&par%26am%61x=1#frag", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, "index.html", "query&par%26am%61x=1", "frag"}, { "http://example.com/index.html?#", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "example.com", NULL, "index.html", "", ""}, { "碼標準萬國碼.com", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "xn--9cs565brid46mda086o.com", NULL, NULL, NULL, NULL}, // { "ftp://cnn.example.com&[email protected]/top_story.htm", NULL,"ftp",NULL,NULL,"cnn.example.com",NULL,NULL,"[email protected]/top_story.htm",NULL } { "ftp://[email protected]/top_story.htm", NULL, "ftp", NULL, NULL, "cnn.example.com", NULL, NULL, "[email protected]/top_story.htm", NULL}, // { "site;sub:.html", NULL, WGET_IRI_SCHEME_HTTP, NULL, NULL, "site", NULL, ";sub:.html", NULL, NULL}, { "mailto:[email protected]", NULL, "mailto", "info", NULL, "example.com", NULL, NULL, NULL, NULL}, }; unsigned it; for (it = 0; it < countof(test_data); it++) { const struct iri_test_data *t = &test_data[it]; wget_iri_t *iri = wget_iri_parse(t->uri, "utf-8"); if (wget_strcmp(iri->display, t->display) || wget_strcmp(iri->scheme, t->scheme) || wget_strcmp(iri->userinfo, t->userinfo) || wget_strcmp(iri->password, t->password) || wget_strcmp(iri->host, t->host) || wget_strcmp(iri->port, t->port) || wget_strcmp(iri->path, t->path) || wget_strcmp(iri->query, t->query) || wget_strcmp(iri->fragment, t->fragment)) { failed++; printf("IRI test #%u failed:\n", it + 1); printf(" [%s]\n", iri->uri); printf(" display %s (expected %s)\n", iri->display, t->display); printf(" scheme %s (expected %s)\n", iri->scheme, t->scheme); printf(" user %s (expected %s)\n", iri->userinfo, t->userinfo); printf(" host %s (expected %s)\n", iri->host, t->host); printf(" port %s (expected %s)\n", iri->port, t->port); printf(" path %s (expected %s)\n", iri->path, t->path); printf(" query %s (expected %s)\n", iri->query, t->query); printf(" fragment %s (expected %s)\n", iri->fragment, t->fragment); printf("\n"); } else { ok++; } wget_iri_free(&iri); } }