| 53 CX_TEST_ASSERTM(tm->tm_sec == 0, "t2: wrong second"); |
53 CX_TEST_ASSERTM(tm->tm_sec == 0, "t2: wrong second"); |
| 54 |
54 |
| 55 } |
55 } |
| 56 } |
56 } |
| 57 |
57 |
| |
58 CX_TEST(test_util_url_base) { |
| |
59 CX_TEST_DO { |
| |
60 char *path = util_url_base("http://example.com/basepath/123/"); |
| |
61 CX_TEST_ASSERT(path && !strcmp(path, "http://example.com/")); |
| |
62 free(path); |
| |
63 |
| |
64 path = util_url_base("http://example.com/"); |
| |
65 CX_TEST_ASSERT(path && !strcmp(path, "http://example.com/")); |
| |
66 free(path); |
| |
67 |
| |
68 path = util_url_base("https://example.com/basepath/123/"); |
| |
69 CX_TEST_ASSERT(path && !strcmp(path, "https://example.com/")); |
| |
70 free(path); |
| |
71 |
| |
72 path = util_url_base("https://example.com/"); |
| |
73 CX_TEST_ASSERT(path && !strcmp(path, "https://example.com/")); |
| |
74 free(path); |
| |
75 |
| |
76 path = util_url_base("http://example.com:8080/basepath/123/"); |
| |
77 CX_TEST_ASSERT(path && !strcmp(path, "http://example.com:8080/")); |
| |
78 free(path); |
| |
79 |
| |
80 path = util_url_base("http://user@example.com/"); |
| |
81 CX_TEST_ASSERT(path && !strcmp(path, "http://user@example.com/")); |
| |
82 free(path); |
| |
83 |
| |
84 //path = util_url_base("http://example.com"); |
| |
85 //CX_TEST_ASSERT(path && !strcmp(path, "http://example.com/")); |
| |
86 //free(path); |
| |
87 } |
| |
88 } |
| |
89 |
| |
90 CX_TEST(test_util_concat_path) { |
| |
91 CX_TEST_DO { |
| |
92 char *str = util_concat_path("", ""); |
| |
93 CX_TEST_ASSERT(str); |
| |
94 CX_TEST_ASSERT(!strcmp(str, "/")); |
| |
95 free(str); |
| |
96 |
| |
97 str = util_concat_path("/test", "abc"); |
| |
98 CX_TEST_ASSERT(str); |
| |
99 CX_TEST_ASSERT(!cx_strcmp(str, "/test/abc")); |
| |
100 free(str); |
| |
101 |
| |
102 str = util_concat_path("/test/", "abc"); |
| |
103 CX_TEST_ASSERT(str); |
| |
104 CX_TEST_ASSERT(!cx_strcmp(str, "/test/abc")); |
| |
105 free(str); |
| |
106 |
| |
107 str = util_concat_path("/test", "/abc"); |
| |
108 CX_TEST_ASSERT(str); |
| |
109 CX_TEST_ASSERT(!cx_strcmp(str, "/test/abc")); |
| |
110 free(str); |
| |
111 |
| |
112 str = util_concat_path("/test/", "/abc"); |
| |
113 CX_TEST_ASSERT(str); |
| |
114 CX_TEST_ASSERT(!cx_strcmp(str, "/test/abc")); |
| |
115 free(str); |
| |
116 |
| |
117 str = util_concat_path("/test/123/long", "/dir1/dir2/dir3"); |
| |
118 CX_TEST_ASSERT(str); |
| |
119 CX_TEST_ASSERT(!cx_strcmp(str, "/test/123/long/dir1/dir2/dir3")); |
| |
120 free(str); |
| |
121 |
| |
122 str = util_concat_path("relative", "path"); |
| |
123 CX_TEST_ASSERT(str); |
| |
124 CX_TEST_ASSERT(!cx_strcmp(str, "relative/path")); |
| |
125 free(str); |
| |
126 } |
| |
127 } |
| |
128 |
| |
129 |
| |
130 |
| 58 CX_TEST(test_util_path_isrelated) { |
131 CX_TEST(test_util_path_isrelated) { |
| 59 CX_TEST_DO { |
132 CX_TEST_DO { |
| 60 CX_TEST_ASSERT(util_path_isrelated("/", "/")); |
133 CX_TEST_ASSERT(util_path_isrelated("/", "/")); |
| 61 CX_TEST_ASSERT(util_path_isrelated("/", "/test")); |
134 CX_TEST_ASSERT(util_path_isrelated("/", "/test")); |
| 62 CX_TEST_ASSERT(util_path_isrelated("/", "/test/")); |
135 CX_TEST_ASSERT(util_path_isrelated("/", "/test/")); |