Skip to content

Commit bf90c01

Browse files
committed
Added tests for url tokenization
1 parent fa7e247 commit bf90c01

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/unit/http_utils_test.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,33 @@ LT_BEGIN_AUTO_TEST(http_utils_suite, unescape_plus)
7070
LT_CHECK_EQ(expected_size, 3);
7171
LT_END_AUTO_TEST(unescape_plus)
7272

73+
LT_BEGIN_AUTO_TEST(http_utils_suite, tokenize_url)
74+
string value = "test/this/url/here";
75+
string expected_arr[] = { "test", "this", "url", "here" };
76+
vector<string> expected(expected_arr, expected_arr + sizeof(expected_arr) / sizeof(expected_arr[0]));
77+
vector<string> actual = http::http_utils::tokenize_url(value, '/');
78+
79+
LT_CHECK_COLLECTIONS_EQ(expected.begin(), expected.end(), actual.begin());
80+
LT_END_AUTO_TEST(tokenize_url)
81+
82+
LT_BEGIN_AUTO_TEST(http_utils_suite, tokenize_url_multiple_spaces)
83+
string value = "test//this//url//here";
84+
string expected_arr[] = { "test", "this", "url", "here" };
85+
vector<string> expected(expected_arr, expected_arr + sizeof(expected_arr) / sizeof(expected_arr[0]));
86+
vector<string> actual = http::http_utils::tokenize_url(value, '/');
87+
88+
LT_CHECK_COLLECTIONS_EQ(expected.begin(), expected.end(), actual.begin());
89+
LT_END_AUTO_TEST(tokenize_url_multiple_spaces)
90+
91+
LT_BEGIN_AUTO_TEST(http_utils_suite, tokenize_url_end_slash)
92+
string value = "test/this/url/here/";
93+
string expected_arr[] = { "test", "this", "url", "here" };
94+
vector<string> expected(expected_arr, expected_arr + sizeof(expected_arr) / sizeof(expected_arr[0]));
95+
vector<string> actual = http::http_utils::tokenize_url(value, '/');
96+
97+
LT_CHECK_COLLECTIONS_EQ(expected.begin(), expected.end(), actual.begin());
98+
LT_END_AUTO_TEST(tokenize_url_end_slash)
99+
73100
LT_BEGIN_AUTO_TEST(http_utils_suite, standardize_url)
74101
string url = "/", result;
75102
result = http::http_utils::standardize_url(url);

0 commit comments

Comments
 (0)