From: Adam Dickmeiss Date: Fri, 22 May 2015 08:46:03 +0000 (+0200) Subject: Add tests for cs_get_host_args YAZ-842 X-Git-Tag: v5.12.2~1 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=870d2233f4071fc1096e4adb41ed87380a2f4bce Add tests for cs_get_host_args YAZ-842 --- diff --git a/test/test_comstack.c b/test/test_comstack.c index fedf567..381ecb8 100644 --- a/test/test_comstack.c +++ b/test/test_comstack.c @@ -266,6 +266,33 @@ static int comstack_example(const char *server_address_str) return 0; } +static void tst_cs_get_host_args(void) +{ + const char *arg = 0; + + cs_get_host_args("http://localhost:9999", &arg); + YAZ_CHECK(arg && !strcmp(arg, "")); + cs_get_host_args("http://localhost:9999/x", &arg); + YAZ_CHECK(arg && !strcmp(arg, "x")); + cs_get_host_args("http://localhost:9999?x", &arg); + YAZ_CHECK(arg && !strcmp(arg, "")); + cs_get_host_args("localhost:9999", &arg); + YAZ_CHECK(arg && !strcmp(arg, "")); + cs_get_host_args("localhost:9999/", &arg); + YAZ_CHECK(arg && !strcmp(arg, "")); + cs_get_host_args("localhost:9999/x&url=http://some.host", &arg); + YAZ_CHECK(arg && !strcmp(arg, "x&url=http://some.host")); + cs_get_host_args("http://localhost:9999/x&url=http://some.host", &arg); + YAZ_CHECK(arg && !strcmp(arg, "x&url=http://some.host")); + cs_get_host_args("http:/localhost:9999/x", &arg); + YAZ_CHECK(arg && !strcmp(arg, "localhost:9999/x")); + cs_get_host_args("http//localhost:9999/x", &arg); + YAZ_CHECK(arg && !strcmp(arg, "/localhost:9999/x")); + cs_get_host_args("http://y/x", &arg); + YAZ_CHECK(arg && !strcmp(arg, "x")); + cs_get_host_args("http:///x", &arg); + YAZ_CHECK(arg && !strcmp(arg, "x")); +} int main (int argc, char **argv) { @@ -275,6 +302,7 @@ int main (int argc, char **argv) comstack_example(argv[1]); tst_http_request(); tst_http_response(); + tst_cs_get_host_args(); YAZ_CHECK_TERM; }