Add tests for c_simple_http_strip_path(...)
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 1m30s

This commit is contained in:
Stephen Seo 2024-09-16 12:04:21 +09:00
parent f15452baa4
commit 47d7f0396d

View file

@ -460,6 +460,46 @@ int main(void) {
ret = simple_archiver_hash_map_get(headers_map, "host", 5);
ASSERT_TRUE(ret);
CHECK_STREQ(ret, "Host: some host");
char *stripped_path_buf = c_simple_http_strip_path("/", 1);
CHECK_STREQ(stripped_path_buf, "/");
free(stripped_path_buf);
stripped_path_buf = c_simple_http_strip_path("//", 2);
CHECK_STREQ(stripped_path_buf, "/");
free(stripped_path_buf);
stripped_path_buf = c_simple_http_strip_path("///", 3);
CHECK_STREQ(stripped_path_buf, "/");
free(stripped_path_buf);
stripped_path_buf = c_simple_http_strip_path("/someurl", 8);
CHECK_STREQ(stripped_path_buf, "/someurl");
free(stripped_path_buf);
stripped_path_buf = c_simple_http_strip_path("/someurl/", 9);
CHECK_STREQ(stripped_path_buf, "/someurl");
free(stripped_path_buf);
stripped_path_buf = c_simple_http_strip_path("/someurl/////", 13);
CHECK_STREQ(stripped_path_buf, "/someurl");
free(stripped_path_buf);
stripped_path_buf = c_simple_http_strip_path("/someurl?key=value", 18);
CHECK_STREQ(stripped_path_buf, "/someurl");
free(stripped_path_buf);
stripped_path_buf = c_simple_http_strip_path("/someurl#client_data", 20);
CHECK_STREQ(stripped_path_buf, "/someurl");
free(stripped_path_buf);
stripped_path_buf = c_simple_http_strip_path("/someurl////?key=value", 22);
CHECK_STREQ(stripped_path_buf, "/someurl");
free(stripped_path_buf);
stripped_path_buf = c_simple_http_strip_path("/someurl///#client_data", 23);
CHECK_STREQ(stripped_path_buf, "/someurl");
free(stripped_path_buf);
}
RETURN()