mirror of
https://github.com/mirror/wget.git
synced 2025-03-14 03:40:15 +08:00
Add new unit test test_uri_merge()
* src/url.c: New test function test_uri_merge(). * tests/unit-tests.c (tests/unit-tests.c): Call test_uri_merge(). * tests/unit-tests.h (tests/unit-tests.h): Declare test_uri_merge().
This commit is contained in:
parent
fbbdf9ea01
commit
834d090bf6
27
src/url.c
27
src/url.c
@ -2525,6 +2525,33 @@ test_are_urls_equal(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
test_uri_merge(void)
|
||||
{
|
||||
static const struct test_data {
|
||||
const char *url;
|
||||
const char *link;
|
||||
const char *expected;
|
||||
} test_data[] = {
|
||||
{ "http://www.yoyodyne.com/path/", "somepage.html", "http://www.yoyodyne.com/path/somepage.html" },
|
||||
{ "http://example.com/path/", "//other.com/somepage.html", "http://other.com/somepage.html" },
|
||||
{ "https://example.com/path/", "//other.com/somepage.html", "https://other.com/somepage.html" },
|
||||
};
|
||||
|
||||
for (unsigned i = 0; i < countof(test_data); ++i)
|
||||
{
|
||||
const struct test_data *t = &test_data[i];
|
||||
char *result = uri_merge (t->url, t->link);
|
||||
bool ok = strcmp (result, t->expected) == 0;
|
||||
if (ok)
|
||||
return aprintf ("test_uri_merge [%u]: expected '%s', got '%s'", i, t->expected, result);
|
||||
|
||||
xfree (result);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* TESTING */
|
||||
|
||||
/*
|
||||
|
@ -58,6 +58,7 @@ all_tests(void)
|
||||
mu_run_test (test_path_simplify);
|
||||
mu_run_test (test_append_uri_pathel);
|
||||
mu_run_test (test_are_urls_equal);
|
||||
mu_run_test (test_uri_merge);
|
||||
mu_run_test (test_is_robots_txt_url);
|
||||
#ifdef HAVE_HSTS
|
||||
mu_run_test (test_hsts_new_entry);
|
||||
|
@ -55,6 +55,7 @@ const char *test_is_robots_txt_url(void);
|
||||
const char *test_path_simplify (void);
|
||||
const char *test_append_uri_pathel(void);
|
||||
const char *test_are_urls_equal(void);
|
||||
const char *test_uri_merge(void);
|
||||
const char *test_subdir_p(void);
|
||||
const char *test_dir_matches_p(void);
|
||||
const char *test_hsts_new_entry(void);
|
||||
|
Loading…
Reference in New Issue
Block a user