#include "uri.h"
#include "../util/util.h"
UCX_TEST(test_util_uri_escape_alphanum) {
char *str1 =
"/test/path/abc/";
char str_enc[
512];
UCX_TEST_BEGIN;
char *test = util_uri_escape(str_enc, str1);
UCX_TEST_ASSERT(test,
"util_uri_escape returned NULL");
UCX_TEST_ASSERT(!strcasecmp(test, str1),
"test != str1");
UCX_TEST_END;
}
UCX_TEST(test_util_uri_escape_space) {
char *str1 =
"/test/space in path/";
char *str_enc_expected =
"/test/space%20in%20path/";
char str_enc[
512];
UCX_TEST_BEGIN;
char *test = util_uri_escape(str_enc, str1);
UCX_TEST_ASSERT(test,
"util_uri_escape returned NULL");
UCX_TEST_ASSERT(!strcasecmp(test, str_enc_expected),
"unexpected result");
UCX_TEST_END;
}
UCX_TEST(test_util_uri_escape_latin) {
char *str1 =
"/test/path/öäütestß/";
char *str_enc_expected =
"/test/path/%C3%B6%C3%A4%C3%BCtest%C3%9F/";
char *str2 =
"€";
char *str2_enc_expected =
"%E2%82%AC";
char str_enc[
512];
UCX_TEST_BEGIN;
char *test = util_uri_escape(str_enc, str1);
UCX_TEST_ASSERT(test,
"util_uri_escape returned NULL");
UCX_TEST_ASSERT(!strcasecmp(test, str_enc_expected),
"unexpected result");
test = util_uri_escape(str_enc, str2);
UCX_TEST_ASSERT(test,
"(2) util_uri_escape returned NULL");
UCX_TEST_ASSERT(!strcasecmp(test, str2_enc_expected),
"(2) unexpected result");
UCX_TEST_END;
}
UCX_TEST(test_util_uri_escape_kanji) {
char *str1 =
"漢字";
char *str1_enc_expected =
"%E6%BC%A2%E5%AD%97";
char *str2 =
"/test/エンコーディング/漢字/";
char *str2_enc_expected =
"/test/%E3%82%A8%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0/%E6%BC%A2%E5%AD%97/";
char str_enc[
512];
UCX_TEST_BEGIN;
char *test = util_uri_escape(str_enc, str1);
UCX_TEST_ASSERT(test,
"util_uri_escape returned NULL");
UCX_TEST_ASSERT(!strcasecmp(test, str1_enc_expected),
"unexpected result");
test = util_uri_escape(str_enc, str2);
UCX_TEST_ASSERT(test,
"(2) util_uri_escape returned NULL");
UCX_TEST_ASSERT(!strcasecmp(test, str2_enc_expected),
"(2) unexpected result");
UCX_TEST_END;
}