summaryrefslogtreecommitdiff
path: root/test/uri-tests.c
diff options
context:
space:
mode:
authorjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2006-01-06 14:54:32 +0000
committerjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2006-01-06 14:54:32 +0000
commitc745b85ef82e85a4d362fc05e552fbc553f9931a (patch)
tree89ef3465af3408a7d0d3def2f4594b9be1e3e9f8 /test/uri-tests.c
parentbfddad32a9891f417f23a47d517430942adc6393 (diff)
downloadneon-c745b85ef82e85a4d362fc05e552fbc553f9931a.tar.gz
* src/ne_locks.c (CMPWITH): Simplify to reduce number of branches.
* test/uri-tests.c (cmp): Test every comparison for reflexivity; git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@830 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
Diffstat (limited to 'test/uri-tests.c')
-rw-r--r--test/uri-tests.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/test/uri-tests.c b/test/uri-tests.c
index 0b0ad25..15eb83e 100644
--- a/test/uri-tests.c
+++ b/test/uri-tests.c
@@ -157,13 +157,10 @@ static int cmp(void)
{ "http://example.com/alpha", "http://www.example.com/alpha" },
{ "http://example.com:443/alpha", "http://example.com:8080/alpha" },
{ "http://example.com/alpha", "http://jim@example.com/alpha" },
- { "http://jim@example.com/alpha", "http://example.com/alpha" },
- { "http://bobexample.com/alpha", "http://jim@example.com/alpha" },
+ { "http://bob@example.com/alpha", "http://jim@example.com/alpha" },
{ "http://example.com/alpha", "http://example.com/alpha?fish" },
- { "http://example.com/alpha?fish", "http://example.com/alpha" },
{ "http://example.com/alpha?fish", "http://example.com/alpha?food" },
{ "http://example.com/alpha", "http://example.com/alpha#foo" },
- { "http://example.com/alpha#foo", "http://example.com/alpha" },
{ "http://example.com/alpha#bar", "http://example.com/alpha#foo" },
{ "http://example.com/alpha", "//example.com/alpha" },
{ "http://example.com/alpha", "///alpha" },
@@ -173,16 +170,24 @@ static int cmp(void)
for (n = 0; eq[n].left; n++) {
ne_uri alpha, beta;
-
+ int r1, r2;
+
ONV(ne_uri_parse(eq[n].left, &alpha),
("could not parse left URI '%s'", eq[n].left));
ONV(ne_uri_parse(eq[n].right, &beta),
("could not parse right URI '%s'", eq[n].right));
- ONV(ne_uri_cmp(&alpha, &beta) != 0,
- ("URIs '%s' and '%s' did not compare as equal",
- eq[n].left, eq[n].right));
+ r1 = ne_uri_cmp(&alpha, &beta);
+ r2 = ne_uri_cmp(&beta, &alpha);
+
+ ONV(r1 != 0,
+ ("cmp('%s', '%s') = %d not zero",
+ eq[n].left, eq[n].right, r1));
+
+ ONV(r2 != 0,
+ ("cmp('%s', '%s') = %d not zero",
+ eq[n].right, eq[n].left, r2));
ne_uri_free(&alpha);
ne_uri_free(&beta);
@@ -190,17 +195,25 @@ static int cmp(void)
for (n = 0; diff[n].left; n++) {
ne_uri alpha, beta;
-
+ int r1, r2;
+
ONV(ne_uri_parse(diff[n].left, &alpha),
("could not parse left URI '%s'", diff[n].left));
ONV(ne_uri_parse(diff[n].right, &beta),
("could not parse right URI '%s'", diff[n].right));
- ONV(ne_uri_cmp(&alpha, &beta) == 0,
- ("URIs '%s' and '%s' did not compare as different",
+ r1 = ne_uri_cmp(&alpha, &beta);
+ r2 = ne_uri_cmp(&beta, &alpha);
+
+ ONV(r1 == 0,
+ ("'%s' and '%s' did not compare as different",
diff[n].left, diff[n].right));
+ ONV(r1 + r2 != 0,
+ ("'%s' and '%s' did not compare reflexively (%d vs %d)",
+ diff[n].left, diff[n].right, r1, r2));
+
ne_uri_free(&alpha);
ne_uri_free(&beta);
}