MCPcopy Create free account
hub / github.com/OISF/libhtp / UriIsExpected

Function UriIsExpected

test/test_utils.cpp:290–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290static ::testing::AssertionResult UriIsExpected(const char *expected_var,
291 const char *actual_var,
292 const uri_expected &expected,
293 const htp_uri_t *actual) {
294 std::stringstream msg;
295 bool equal = true;
296
297 if (!bstr_equal_c(actual->scheme, expected.scheme)) {
298 equal = false;
299 append_message(msg, "scheme", expected.scheme, actual->scheme);
300 }
301
302 if (!bstr_equal_c(actual->username, expected.username)) {
303 equal = false;
304 append_message(msg, "username", expected.username, actual->username);
305 }
306
307 if (!bstr_equal_c(actual->password, expected.password)) {
308 equal = false;
309 append_message(msg, "password", expected.password, actual->password);
310 }
311
312 if (!bstr_equal_c(actual->hostname, expected.hostname)) {
313 equal = false;
314 append_message(msg, "hostname", expected.hostname, actual->hostname);
315 }
316
317 if (!bstr_equal_c(actual->port, expected.port)) {
318 equal = false;
319 append_message(msg, "port", expected.port, actual->port);
320 }
321
322 if (!bstr_equal_c(actual->path, expected.path)) {
323 equal = false;
324 append_message(msg, "path", expected.path, actual->path);
325 }
326
327 if (!bstr_equal_c(actual->query, expected.query)) {
328 equal = false;
329 append_message(msg, "query", expected.query, actual->query);
330 }
331
332 if (!bstr_equal_c(actual->fragment, expected.fragment)) {
333 equal = false;
334 append_message(msg, "fragment", expected.fragment, actual->fragment);
335 }
336
337 if (equal) {
338 return ::testing::AssertionSuccess();
339 } else {
340 return ::testing::AssertionFailure() << msg.str();
341 }
342}
343
344struct uri_test uri_tests[] = {
345 {"http://user:pass@www.example.com:1234/path1/path2?a=b&c=d#frag",

Callers

nothing calls this directly

Calls 4

bstr_equal_cFunction · 0.85
append_messageFunction · 0.85
AssertionSuccessFunction · 0.85
AssertionFailureFunction · 0.85

Tested by

no test coverage detected