From 870d2233f4071fc1096e4adb41ed87380a2f4bce Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 22 May 2015 10:46:03 +0200 Subject: [PATCH] Add tests for cs_get_host_args YAZ-842 --- test/test_comstack.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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; } -- 1.7.10.4