Commit 20630bf4 authored by Pekka Pessi's avatar Pekka Pessi
Browse files

url tests: using TEST_P() and TEST_SIZE().

darcs-hash:20061121185759-65a35-60eb72b64fa9e2fe122e496c771febdabdee8180.gz
parent 11a72bb3
...@@ -91,12 +91,12 @@ int test_quote(void) ...@@ -91,12 +91,12 @@ int test_quote(void)
TEST_1(!url_reserved_p("")); TEST_1(!url_reserved_p(""));
TEST_1(url_reserved_p("foobar:bar")); TEST_1(url_reserved_p("foobar:bar"));
TEST(url_esclen("a" EXCLUDED, ""), TEST_SIZE(url_esclen("a" EXCLUDED, ""),
1 + strlen(RESERVED) + 3 * strlen(DELIMS UNWISE)); 1 + strlen(RESERVED) + 3 * strlen(DELIMS UNWISE));
TEST(url_esclen("a" EXCLUDED, DELIMS UNWISE), TEST_SIZE(url_esclen("a" EXCLUDED, DELIMS UNWISE),
1 + strlen(RESERVED) + 3 * strlen(DELIMS UNWISE)); 1 + strlen(RESERVED) + 3 * strlen(DELIMS UNWISE));
TEST(url_esclen("a" EXCLUDED, EXCLUDED), 1 + 3 * strlen(EXCLUDED)); TEST_SIZE(url_esclen("a" EXCLUDED, EXCLUDED), 1 + 3 * strlen(EXCLUDED));
TEST(url_esclen("a" EXCLUDED, NULL), 1 + 3 * strlen(EXCLUDED)); TEST_SIZE(url_esclen("a" EXCLUDED, NULL), 1 + 3 * strlen(EXCLUDED));
TEST_S(url_escape(escaped, "a" EXCLUDED, NULL), TEST_S(url_escape(escaped, "a" EXCLUDED, NULL),
"a%3B%2F%3F%3A%40%26%3D%2B%24%2C" "a%3B%2F%3F%3A%40%26%3D%2B%24%2C"
...@@ -104,7 +104,7 @@ int test_quote(void) ...@@ -104,7 +104,7 @@ int test_quote(void)
"%7B%7D%7C%5C%5E%5B%5D%60"); "%7B%7D%7C%5C%5E%5B%5D%60");
TEST_S(url_unescape(escaped, escaped), "a" EXCLUDED); TEST_S(url_unescape(escaped, escaped), "a" EXCLUDED);
TEST(url_esclen(UNRESERVED, NULL), strlen(UNRESERVED)); TEST_SIZE(url_esclen(UNRESERVED, NULL), strlen(UNRESERVED));
TEST_S(url_escape(unreserved, UNRESERVED, NULL), UNRESERVED); TEST_S(url_escape(unreserved, UNRESERVED, NULL), UNRESERVED);
TEST_S(url_unescape(unreserved, UNRESERVED), UNRESERVED); TEST_S(url_unescape(unreserved, UNRESERVED), UNRESERVED);
...@@ -191,8 +191,8 @@ int test_any(void) ...@@ -191,8 +191,8 @@ int test_any(void)
char buf[6]; char buf[6];
TEST_1(u = url_hdup(home, (void *)"error")); TEST_1(u = url_hdup(home, (void *)"error"));
TEST(url_xtra(u), 6); TEST_SIZE(url_xtra(u), 6);
TEST(url_dup(buf, 6, url, u), 6); TEST_SIZE(url_dup(buf, 6, url, u), 6);
TEST_S(buf, "error"); TEST_S(buf, "error");
} }
...@@ -256,13 +256,13 @@ int test_sip(void) ...@@ -256,13 +256,13 @@ int test_sip(void)
TEST(url->url_root, 0); TEST(url->url_root, 0);
TEST_S(url->url_scheme, "sip"); TEST_S(url->url_scheme, "sip");
TEST_S(url->url_user, "pekka.pessi"); TEST_S(url->url_user, "pekka.pessi");
TEST(url->url_password, NULL); TEST_P(url->url_password, NULL);
TEST_S(url->url_host, "nokia.com"); TEST_S(url->url_host, "nokia.com");
TEST(url->url_port, NULL); TEST_P(url->url_port, NULL);
TEST(url->url_path, NULL); TEST_P(url->url_path, NULL);
TEST_S(url->url_params, "method=MESSAGE"); TEST_S(url->url_params, "method=MESSAGE");
TEST_S(url->url_headers, "body=CANNED%20MSG"); TEST_S(url->url_headers, "body=CANNED%20MSG");
TEST(url->url_fragment, NULL); TEST_P(url->url_fragment, NULL);
sip->url_user = "user"; sip->url_user = "user";
sip->url_password = "pass"; sip->url_password = "pass";
...@@ -283,8 +283,8 @@ int test_sip(void) ...@@ -283,8 +283,8 @@ int test_sip(void)
TEST_1(url_cmp(sip, u) == 0); TEST_1(url_cmp(sip, u) == 0);
TEST_1(url_e(sip2, sizeof(sip2), u) == strlen(sipurl)); TEST_1(url_e(sip2, sizeof(sip2), u) == strlen(sipurl));
TEST_1(strcmp(sip2, sipurl) == 0); TEST_1(strcmp(sip2, sipurl) == 0);
TEST(snprintf(sip2, sizeof(sip2), URL_PRINT_FORMAT, TEST_SIZE(snprintf(sip2, sizeof(sip2), URL_PRINT_FORMAT,
URL_PRINT_ARGS(sip)), strlen(sipurl)); URL_PRINT_ARGS(sip)), strlen(sipurl));
TEST_1(strcmp(sip2, sipurl) == 0); TEST_1(strcmp(sip2, sipurl) == 0);
url_digest(hash1, sizeof(hash1), url, NULL); url_digest(hash1, sizeof(hash1), url, NULL);
...@@ -312,7 +312,7 @@ int test_sip(void) ...@@ -312,7 +312,7 @@ int test_sip(void)
url_t dst[1]; url_t dst[1];
buf[i] = '\377'; buf[i] = '\377';
TEST(url_dup(buf, i, dst, url), sizeof(sipsurl) - 1 - strlen("sips")); TEST_SIZE(url_dup(buf, i, dst, url), sizeof(sipsurl) - 1 - strlen("sips"));
TEST(buf[i], '\377'); TEST(buf[i], '\377');
} }
...@@ -323,9 +323,9 @@ int test_sip(void) ...@@ -323,9 +323,9 @@ int test_sip(void)
u = url_hdup(home, (url_t*)"SIP:test@127.0.0.1:55"); TEST_1(u); u = url_hdup(home, (url_t*)"SIP:test@127.0.0.1:55"); TEST_1(u);
TEST(u->url_type, url_sip); TEST(u->url_type, url_sip);
TEST(url_hdup(home, (url_t*)"sip:test@127.0.0.1::55"), NULL); TEST_P(url_hdup(home, (url_t*)"sip:test@127.0.0.1::55"), NULL);
TEST(url_hdup(home, (url_t*)"sip:test@127.0.0.1:55:"), NULL); TEST_P(url_hdup(home, (url_t*)"sip:test@127.0.0.1:55:"), NULL);
TEST(url_hdup(home, (url_t*)"sip:test@127.0.0.1:sip"), NULL); TEST_P(url_hdup(home, (url_t*)"sip:test@127.0.0.1:sip"), NULL);
for (i = 32; i <= 256; i++) { for (i = 32; i <= 256; i++) {
char pu[512]; char pu[512];
...@@ -351,7 +351,7 @@ int test_sip(void) ...@@ -351,7 +351,7 @@ int test_sip(void)
TEST_1(u); TEST_1(u);
TEST_1(url_have_transport(u)); TEST_1(url_have_transport(u));
TEST_1(url_strip_transport(u)); TEST_1(url_strip_transport(u));
TEST(u->url_params, NULL); TEST_P(u->url_params, NULL);
TEST_1(!url_have_transport(u)); TEST_1(!url_have_transport(u));
u = url_hdup(home, (void*)"sip:u:p@host:5060;user=phone;ttl=1;isfocus"); u = url_hdup(home, (void*)"sip:u:p@host:5060;user=phone;ttl=1;isfocus");
...@@ -457,10 +457,10 @@ int test_wv(void) ...@@ -457,10 +457,10 @@ int test_wv(void)
TEST_1(u = url_hdup(home, url)); TEST_1(u = url_hdup(home, url));
TEST(u->url_type, url_wv); TEST(u->url_type, url_wv);
TEST_1(url_cmp(wv, u) == 0); TEST_1(url_cmp(wv, u) == 0);
TEST(url_e(wv2, sizeof(wv2), u), strlen(wvurl)); TEST_SIZE(url_e(wv2, sizeof(wv2), u), strlen(wvurl));
TEST_1(strcmp(wv2, wvurl) == 0); TEST_1(strcmp(wv2, wvurl) == 0);
TEST(snprintf(wv2, sizeof(wv2), URL_PRINT_FORMAT, TEST_SIZE(snprintf(wv2, sizeof(wv2), URL_PRINT_FORMAT,
URL_PRINT_ARGS(wv)), strlen(wvurl)); URL_PRINT_ARGS(wv)), strlen(wvurl));
TEST_1(strcmp(wv2, wvurl) == 0); TEST_1(strcmp(wv2, wvurl) == 0);
url_digest(hash1, sizeof(hash1), url, NULL); url_digest(hash1, sizeof(hash1), url, NULL);
...@@ -509,10 +509,10 @@ int test_tel(void) ...@@ -509,10 +509,10 @@ int test_tel(void)
TEST_1(u = url_hdup(home, url)); TEST_1(u = url_hdup(home, url));
TEST(u->url_type, url_tel); TEST(u->url_type, url_tel);
TEST_1(url_cmp(tel, u) == 0); TEST_1(url_cmp(tel, u) == 0);
TEST(url_e(tel2, sizeof(tel2), u), strlen(telurl)); TEST_SIZE(url_e(tel2, sizeof(tel2), u), strlen(telurl));
TEST_1(strcmp(tel2, telurl) == 0); TEST_1(strcmp(tel2, telurl) == 0);
TEST(snprintf(tel2, sizeof(tel2), URL_PRINT_FORMAT, TEST_SIZE(snprintf(tel2, sizeof(tel2), URL_PRINT_FORMAT,
URL_PRINT_ARGS(tel)), strlen(telurl)); URL_PRINT_ARGS(tel)), strlen(telurl));
TEST_1(strcmp(tel2, telurl) == 0); TEST_1(strcmp(tel2, telurl) == 0);
url_digest(hash1, sizeof(hash1), url, NULL); url_digest(hash1, sizeof(hash1), url, NULL);
...@@ -559,10 +559,10 @@ int test_fax(void) ...@@ -559,10 +559,10 @@ int test_fax(void)
TEST_1(u = url_hdup(home, url)); TEST_1(u = url_hdup(home, url));
TEST(u->url_type, url_fax); TEST(u->url_type, url_fax);
TEST_1(url_cmp(fax, u) == 0); TEST_1(url_cmp(fax, u) == 0);
TEST(url_e(fax2, sizeof(fax2), u), strlen(faxurl)); TEST_SIZE(url_e(fax2, sizeof(fax2), u), strlen(faxurl));
TEST_1(strcmp(fax2, faxurl) == 0); TEST_1(strcmp(fax2, faxurl) == 0);
TEST(snprintf(fax2, sizeof(fax2), URL_PRINT_FORMAT, TEST_SIZE(snprintf(fax2, sizeof(fax2), URL_PRINT_FORMAT,
URL_PRINT_ARGS(fax)), strlen(faxurl)); URL_PRINT_ARGS(fax)), strlen(faxurl));
TEST_1(strcmp(fax2, faxurl) == 0); TEST_1(strcmp(fax2, faxurl) == 0);
...@@ -604,10 +604,10 @@ int test_modem(void) ...@@ -604,10 +604,10 @@ int test_modem(void)
TEST_1(u = url_hdup(home, url)); TEST_1(u = url_hdup(home, url));
TEST(u->url_type, url_modem); TEST(u->url_type, url_modem);
TEST_1(url_cmp(modem, u) == 0); TEST_1(url_cmp(modem, u) == 0);
TEST(url_e(modem2, sizeof(modem2), u), strlen(modemurl)); TEST_SIZE(url_e(modem2, sizeof(modem2), u), strlen(modemurl));
TEST_1(strcmp(modem2, modemurl) == 0); TEST_1(strcmp(modem2, modemurl) == 0);
TEST(snprintf(modem2, sizeof(modem2), URL_PRINT_FORMAT, TEST_SIZE(snprintf(modem2, sizeof(modem2), URL_PRINT_FORMAT,
URL_PRINT_ARGS(modem)), strlen(modemurl)); URL_PRINT_ARGS(modem)), strlen(modemurl));
TEST_1(strcmp(modem2, modemurl) == 0); TEST_1(strcmp(modem2, modemurl) == 0);
url_digest(hash1, sizeof(hash1), url, NULL); url_digest(hash1, sizeof(hash1), url, NULL);
...@@ -643,10 +643,10 @@ int test_file(void) ...@@ -643,10 +643,10 @@ int test_file(void)
TEST_1(u = url_hdup(home, url)); TEST_1(u = url_hdup(home, url));
TEST(u->url_type, url_file); TEST(u->url_type, url_file);
TEST(url_cmp(file, u), 0); TEST(url_cmp(file, u), 0);
TEST(url_e(buf1, sizeof(buf1), u), strlen(fileurl)); TEST_SIZE(url_e(buf1, sizeof(buf1), u), strlen(fileurl));
TEST_S(buf1, fileurl); TEST_S(buf1, fileurl);
TEST(snprintf(buf2, sizeof(buf2), URL_PRINT_FORMAT, URL_PRINT_ARGS(u)), TEST_SIZE(snprintf(buf2, sizeof(buf2), URL_PRINT_FORMAT, URL_PRINT_ARGS(u)),
strlen(fileurl)); strlen(fileurl));
TEST_S(buf2, fileurl); TEST_S(buf2, fileurl);
url_digest(hash1, sizeof(hash1), url, NULL); url_digest(hash1, sizeof(hash1), url, NULL);
...@@ -699,10 +699,10 @@ int test_ldap(void) ...@@ -699,10 +699,10 @@ int test_ldap(void)
TEST(u->url_type, url_unknown); TEST(u->url_type, url_unknown);
TEST_S(u->url_scheme, "ldap"); TEST_S(u->url_scheme, "ldap");
TEST(url_cmp(ldap, u), 0); TEST(url_cmp(ldap, u), 0);
TEST(url_e(buf1, sizeof(buf1), u), strlen(ldapurl)); TEST_SIZE(url_e(buf1, sizeof(buf1), u), strlen(ldapurl));
TEST_S(buf1, ldapurl); TEST_S(buf1, ldapurl);
TEST(snprintf(buf2, sizeof(buf2), URL_PRINT_FORMAT, URL_PRINT_ARGS(u)), TEST_SIZE(snprintf(buf2, sizeof(buf2), URL_PRINT_FORMAT, URL_PRINT_ARGS(u)),
strlen(ldapurl)); strlen(ldapurl));
TEST_S(buf2, ldapurl); TEST_S(buf2, ldapurl);
url_digest(hash1, sizeof(hash1), url, NULL); url_digest(hash1, sizeof(hash1), url, NULL);
...@@ -744,8 +744,8 @@ int test_rtsp(void) ...@@ -744,8 +744,8 @@ int test_rtsp(void)
TEST_1(url_cmp(rtsp, u) == 0); TEST_1(url_cmp(rtsp, u) == 0);
TEST_1(url_e(rtsp2, sizeof(rtsp2), u) == strlen(rtspurl)); TEST_1(url_e(rtsp2, sizeof(rtsp2), u) == strlen(rtspurl));
TEST_1(strcmp(rtsp2, rtspurl) == 0); TEST_1(strcmp(rtsp2, rtspurl) == 0);
TEST(snprintf(rtsp2, sizeof(rtsp2), URL_PRINT_FORMAT, TEST_SIZE(snprintf(rtsp2, sizeof(rtsp2), URL_PRINT_FORMAT,
URL_PRINT_ARGS(rtsp)), strlen(rtspurl)); URL_PRINT_ARGS(rtsp)), strlen(rtspurl));
TEST_1(strcmp(rtsp2, rtspurl) == 0); TEST_1(strcmp(rtsp2, rtspurl) == 0);
url_digest(hash1, sizeof(hash1), url, NULL); url_digest(hash1, sizeof(hash1), url, NULL);
...@@ -805,10 +805,10 @@ int test_http(void) ...@@ -805,10 +805,10 @@ int test_http(void)
TEST_1(u = url_hdup(home, url)); TEST_1(u = url_hdup(home, url));
TEST(u->url_type, url_http); TEST(u->url_type, url_http);
TEST_1(url_cmp(http, u) == 0); TEST_1(url_cmp(http, u) == 0);
TEST(url_e(http2, sizeof(http2), u), strlen(httpurl)); TEST_SIZE(url_e(http2, sizeof(http2), u), strlen(httpurl));
TEST_1(strcmp(http2, httpurl) == 0); TEST_1(strcmp(http2, httpurl) == 0);
TEST(snprintf(http2, sizeof(http2), URL_PRINT_FORMAT, TEST_SIZE(snprintf(http2, sizeof(http2), URL_PRINT_FORMAT,
URL_PRINT_ARGS(http)), strlen(httpurl)); URL_PRINT_ARGS(http)), strlen(httpurl));
TEST_1(strcmp(http2, httpurl) == 0); TEST_1(strcmp(http2, httpurl) == 0);
url_digest(hash1, sizeof(hash1), http, NULL); url_digest(hash1, sizeof(hash1), http, NULL);
...@@ -947,8 +947,8 @@ int test_tag_filter(void) ...@@ -947,8 +947,8 @@ int test_tag_filter(void)
result = tl_afilter(NULL, filter, lst); result = tl_afilter(NULL, filter, lst);
TEST_1(result); TEST_1(result);
TEST(result[0].t_tag, urltag_url); TEST_P(result[0].t_tag, urltag_url);
TEST(result[1].t_tag, urltag_url); TEST_P(result[1].t_tag, urltag_url);
tl_vfree(lst); tl_vfree(lst);
free(result); free(result);
......
...@@ -565,17 +565,18 @@ int test_path(void) ...@@ -565,17 +565,18 @@ int test_path(void)
o = (void *)-1; o = (void *)-1;
TEST(url_map_insert(&tree, um3, &o), 0); TEST(url_map_insert(&tree, um3, &o), 0);
TEST(o, NULL); o = (void *)-1; TEST_P(o, NULL); o = (void *)-1;
TEST(url_map_insert(&tree, um2, &o), 0); TEST(url_map_insert(&tree, um2, &o), 0);
TEST(o, NULL); o = (void *)-1; TEST_P(o, NULL); o = (void *)-1;
TEST(url_map_insert(&tree, um1, &o), 0); TEST(url_map_insert(&tree, um1, &o), 0);
TEST(o, NULL); TEST_P(o, NULL);
um = url_map_find(tree, (void*)"http://host/aa/bb/cc", 1); TEST(um, um2); um = url_map_find(tree, (void*)"http://host/aa/bb/cc", 1); TEST_P(um, um2);
um = url_map_find(tree, (void*)"http://host/aa/bb/cc/oo", 1); TEST(um, um3); um = url_map_find(tree, (void*)"http://host/aa/bb/cc/oo", 1);
um = url_map_find(tree, (void*)"http://host/aa/bb", 1); TEST(um, um1); TEST_P(um, um3);
um = url_map_find(tree, (void*)"http://host/aa/bb", 0); TEST(um, NULL); um = url_map_find(tree, (void*)"http://host/aa/bb", 1); TEST_P(um, um1);
um = url_map_find(tree, (void*)"http://host/aa/bb/", 1); TEST(um, um2); um = url_map_find(tree, (void*)"http://host/aa/bb", 0); TEST_P(um, NULL);
um = url_map_find(tree, (void*)"http://host/aa/bb/", 1); TEST_P(um, um2);
su_home_check(home); su_home_check(home);
su_home_zap(home); su_home_zap(home);
...@@ -605,10 +606,10 @@ int test_insert(void) ...@@ -605,10 +606,10 @@ int test_insert(void)
TEST_1(seven); TEST_1(seven);
/* Check single node */ /* Check single node */
TEST(url_map_insert(&tree, five, &o), 0); TEST(o, NULL); TEST(url_map_insert(&tree, five, &o), 0); TEST_P(o, NULL);
TEST(tree, five); TEST_P(tree, five);
TEST(five->um_left, NULL); TEST(five->um_right, NULL); TEST_P(five->um_left, NULL); TEST_P(five->um_right, NULL);
TEST(five->um_dad, NULL); TEST(five->um_black, 1); TEST_P(five->um_dad, NULL); TEST(five->um_black, 1);
/* Check after another node: /* Check after another node:
* *
...@@ -616,20 +617,20 @@ int test_insert(void) ...@@ -616,20 +617,20 @@ int test_insert(void)
* / * /
* 3r * 3r
*/ */
TEST(url_map_insert(&tree, three, &o), 0); TEST(o, NULL); TEST(url_map_insert(&tree, three, &o), 0); TEST_P(o, NULL);
TEST(tree->um_left, three); TEST(tree->um_black, 1); TEST_P(tree->um_left, three); TEST(tree->um_black, 1);
TEST(three->um_left, NULL); TEST(three->um_right, NULL); TEST_P(three->um_left, NULL); TEST_P(three->um_right, NULL);
TEST(three->um_dad, tree); TEST(three->um_black, 0); TEST_P(three->um_dad, tree); TEST(three->um_black, 0);
/* Check third node /* Check third node
* 5b * 5b
* / \ * / \
* 3r 7r * 3r 7r
*/ */
TEST(url_map_insert(&tree, seven, &o), 0); TEST(o, NULL); TEST(url_map_insert(&tree, seven, &o), 0); TEST_P(o, NULL);
TEST(tree->um_right, seven); TEST(tree->um_black, 1); TEST_P(tree->um_right, seven); TEST(tree->um_black, 1);
TEST(seven->um_left, NULL); TEST(seven->um_right, NULL); TEST_P(seven->um_left, NULL); TEST_P(seven->um_right, NULL);
TEST(seven->um_dad, tree); TEST(seven->um_black, 0); TEST_P(seven->um_dad, tree); TEST(seven->um_black, 0);
/* Check after fourth node: /* Check after fourth node:
* 5b * 5b
...@@ -638,12 +639,12 @@ int test_insert(void) ...@@ -638,12 +639,12 @@ int test_insert(void)
* / * /
* 1r * 1r
*/ */
TEST(url_map_insert(&tree, one, &o), 0); TEST(o, NULL); TEST(url_map_insert(&tree, one, &o), 0); TEST_P(o, NULL);
TEST(tree->um_left->um_left, one); TEST_P(tree->um_left->um_left, one);
TEST(tree->um_black, 1); TEST(tree->um_black, 1);
TEST(tree->um_left->um_black, 1); TEST(tree->um_right->um_black, 1); TEST(tree->um_left->um_black, 1); TEST(tree->um_right->um_black, 1);
TEST(one->um_left, NULL); TEST(one->um_right, NULL); TEST_P(one->um_left, NULL); TEST_P(one->um_right, NULL);
TEST(one->um_dad, tree->um_left); TEST(one->um_black, 0); TEST_P(one->um_dad, tree->um_left); TEST(one->um_black, 0);
/* Checks that we got after fifth node: /* Checks that we got after fifth node:
* 5b * 5b
...@@ -652,24 +653,24 @@ int test_insert(void) ...@@ -652,24 +653,24 @@ int test_insert(void)
* / / * / /
* 1r 6r * 1r 6r
*/ */
TEST(url_map_insert(&tree, six, &o), 0); TEST(o, NULL); TEST(url_map_insert(&tree, six, &o), 0); TEST_P(o, NULL);
TEST(tree, five); TEST(five->um_black, 1); TEST_P(tree, five); TEST(five->um_black, 1);
TEST(tree->um_left, three); TEST(three->um_black, 1); TEST_P(tree->um_left, three); TEST(three->um_black, 1);
TEST(tree->um_left->um_left, one); TEST(one->um_black, 0); TEST_P(tree->um_left->um_left, one); TEST(one->um_black, 0);
TEST(tree->um_right, seven); TEST(seven->um_black, 1); TEST_P(tree->um_right, seven); TEST(seven->um_black, 1);
TEST(tree->um_right->um_left, six); TEST(six->um_black, 0); TEST_P(tree->um_right->um_left, six); TEST(six->um_black, 0);
/* Insert five second time */ /* Insert five second time */
old = five; old = five;
five = url_map_new(home, (void*)"/5", sizeof (UrlMap)); five = url_map_new(home, (void*)"/5", sizeof (UrlMap));
TEST(url_map_insert(&tree, five, &o), 0); TEST(o, old); TEST(url_map_insert(&tree, five, &o), 0); TEST_P(o, old);
TEST(tree, five); TEST(five->um_black, 1); TEST_P(tree, five); TEST(five->um_black, 1);
TEST(tree->um_left, three); TEST(three->um_black, 1); TEST_P(tree->um_left, three); TEST(three->um_black, 1);
TEST(three->um_dad, five); TEST_P(three->um_dad, five);
TEST(tree->um_left->um_left, one); TEST(one->um_black, 0); TEST_P(tree->um_left->um_left, one); TEST(one->um_black, 0);
TEST(tree->um_right, seven); TEST(seven->um_black, 1); TEST_P(tree->um_right, seven); TEST(seven->um_black, 1);
TEST(seven->um_dad, five); TEST_P(seven->um_dad, five);
TEST(tree->um_right->um_left, six); TEST(six->um_black, 0); TEST_P(tree->um_right->um_left, six); TEST(six->um_black, 0);
su_home_check(home); su_home_check(home);
su_home_zap(home); su_home_zap(home);
...@@ -698,14 +699,14 @@ int test_rotate(void) ...@@ -698,14 +699,14 @@ int test_rotate(void)
* Checks that \ transforms to / and back to \ * Checks that \ transforms to / and back to \
* y x y * y x y
*/ */
TEST(url_map_insert(&tree, x, &o), 0); TEST(o, NULL); TEST(url_map_insert(&tree, x, &o), 0); TEST_P(o, NULL);
TEST(url_map_insert(&tree, y, &o), 0); TEST(o, NULL); TEST(url_map_insert(&tree, y, &o), 0); TEST_P(o, NULL);
TEST(tree, x); TEST(x->um_right, y); TEST_P(tree, x); TEST_P(x->um_right, y);
left_rotate(&tree, x); left_rotate(&tree, x);
TEST(tree, y); TEST(y->um_left, x); TEST_P(tree, y); TEST_P(y->um_left, x);
right_rotate(&tree, y); right_rotate(&tree, y);
TEST(tree, x); TEST(x->um_right, y); TEST_P(tree, x); TEST_P(x->um_right, y);
su_home_check(home); su_home_check(home);
su_home_zap(home); su_home_zap(home);
...@@ -770,7 +771,7 @@ int test_balance(void) ...@@ -770,7 +771,7 @@ int test_balance(void)
te->te_value = i; te->te_value = i;
nodes[i] = te; nodes[i] = te;
TEST(url_map_insert(&tree, te->te_urlmap, &o), 0); TEST(url_map_insert(&tree, te->te_urlmap, &o), 0);
TEST(o, NULL); TEST_P(o, NULL);
TEST_1(url_map_height(tree) <= 2 * log2ceil(i + 1 + 1)); TEST_1(url_map_height(tree) <= 2 * log2ceil(i + 1 + 1));
TEST_1(redblack_check(tree)); TEST_1(redblack_check(tree));
} }
...@@ -792,8 +793,8 @@ int test_balance(void) ...@@ -792,8 +793,8 @@ int test_balance(void)
TEST_1(te == NULL); TEST_1(te == NULL);
for (i = 0; i < N; i++) { for (i = 0; i < N; i++) {
TEST(url_map_succ(nodes[i]->te_urlmap), nodes[i + 1]->te_urlmap); TEST_P(url_map_succ(nodes[i]->te_urlmap), nodes[i + 1]->te_urlmap);
TEST(url_map_prec(nodes[i]->te_urlmap), nodes[i - 1]->te_urlmap); TEST_P(url_map_prec(nodes[i]->te_urlmap), nodes[i - 1]->te_urlmap);
} }
for (i = 0; i < N; i++) { for (i = 0; i < N; i++) {
...@@ -808,19 +809,19 @@ int test_balance(void) ...@@ -808,19 +809,19 @@ int test_balance(void)
TEST_1(redblack_check(tree)); TEST_1(redblack_check(tree));
} }
TEST(tree, NULL); TEST_P(tree, NULL);
for (i = N - 1; i >= 0; i--) { for (i = N - 1; i >= 0; i--) {
o = (void *)-1; o = (void *)-1;
TEST(url_map_insert(&tree, nodes[i]->te_urlmap, &o), 0); TEST(url_map_insert(&tree, nodes[i]->te_urlmap, &o), 0);
TEST(o, NULL); TEST_P(o, NULL);
TEST_1(url_map_height(tree) <= 2 * log2ceil(N - i + 1)); TEST_1(url_map_height(tree) <= 2 * log2ceil(N - i + 1));
TEST_1(redblack_check(tree)); TEST_1(redblack_check(tree));
} }
for (i = 0; i < N; i++) { for (i = 0; i < N; i++) {
TEST(url_map_succ(nodes[i]->te_urlmap), nodes[i + 1]->te_urlmap); TEST_P(url_map_succ(nodes[i]->te_urlmap), nodes[i + 1]->te_urlmap);
TEST(url_map_prec(nodes[i]->te_urlmap), nodes[i - 1]->te_urlmap); TEST_P(url_map_prec(nodes[i]->te_urlmap), nodes[i - 1]->te_urlmap);
} }
for (i = 0; i < N; i++) { for (i = 0; i < N; i++) {
...@@ -829,7 +830,7 @@ int test_balance(void) ...@@ -829,7 +830,7 @@ int test_balance(void)
TEST_1(redblack_check(tree)); TEST_1(redblack_check(tree));
} }
TEST(tree, NULL); TEST_P(tree, NULL);
for (i = 0; i < N; i++) { for (i = 0; i < N; i++) {
int sn = (i * 57) % N; int sn = (i * 57) % N;
...@@ -837,15 +838,15 @@ int test_balance(void) ...@@ -837,15 +838,15 @@ int test_balance(void)
TEST(nodes[sn]->te_inserted, 0); TEST(nodes[sn]->te_inserted, 0);
TEST(url_map_insert(&tree, nodes[sn]->te_urlmap, &o), 0); TEST(url_map_insert(&tree, nodes[sn]->te_urlmap, &o), 0);
nodes[sn]->te_inserted = 1; nodes[sn]->te_inserted = 1;
TEST(o, NULL); TEST_P(o, NULL);
TEST_1(url_map_height(tree) <= 2 * log2ceil(i + 1 + 1)); TEST_1(url_map_height(tree) <= 2 * log2ceil(i + 1 + 1));
TEST_1(redblack_check(tree)); TEST_1(redblack_check(tree));
} }
for (i = 0; i < N; i++) { for (i = 0; i < N; i++) {
TEST(nodes[i]->te_inserted, 1); TEST(nodes[i]->te_inserted, 1);
TEST(url_map_succ(nodes[i]->te_urlmap), nodes[i + 1]->te_urlmap); TEST_P(url_map_succ(nodes[i]->te_urlmap), nodes[i + 1]->te_urlmap);
TEST(url_map_prec(nodes[i]->te_urlmap), nodes[i - 1]->te_urlmap); TEST_P(url_map_prec(nodes[i]->te_urlmap), nodes[i - 1]->te_urlmap);
} }