From: Pietro Cerutti Date: Thu, 15 Nov 2018 16:38:51 +0000 (+0000) Subject: Additional tests for URL X-Git-Tag: 2019-10-25~525^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=daa888b44b13d021de2ede2c200474ab89166d5c;p=neomutt Additional tests for URL --- diff --git a/test/url.c b/test/url.c index 592ab8453..10557a103 100644 --- a/test/url.c +++ b/test/url.c @@ -2,20 +2,35 @@ #include "acutest.h" #include "email/url.h" +typedef bool (*check_query_string)(const struct UrlQueryStringHead *q); + +bool check_query_string_eq(const struct UrlQueryStringHead *q) +{ + const struct UrlQueryString *np = STAILQ_FIRST(q); + if (strcmp(np->name, "encoding") != 0) + return false; + if (strcmp(np->value, "binary") != 0) + return false; + if (STAILQ_NEXT(np, entries) != NULL) + return false; + return true; +} + static struct { const char *source; bool valid; + check_query_string f; struct Url url; } test[] = { { "foobar foobar", false, - {} }, { "imaps://foouser:foopass@imap.example.com:456", true, + NULL, { U_IMAPS, "foouser", @@ -24,6 +39,32 @@ static struct 456, NULL } + }, + { + "SmTp://user@example.com", /* scheme is lower-cased */ + true, + NULL, + { + U_SMTP, + "user", + NULL, + "example.com", + 0, + NULL + } + }, + { + "pop://user@example.com@pop.example.com:234/some/where?encoding=binary", + true, + check_query_string_eq, + { + U_POP, + "user@example.com", + NULL, + "pop.example.com", + 234, + "some/where", + } } }; @@ -73,8 +114,10 @@ void test_url(void) TEST_MSG("Expected: %s", test[i].url.path); TEST_MSG("Actual : %s", url->path); } - - // TODO - test query string + if (test[i].f) + { + TEST_CHECK(test[i].f(&url->query_strings)); + } url_free(&url); }