Fix new strcmp_opt/len tests on OSs where strcmp() can return values >1 or <-1

This commit is contained in:
Nick Mathewson 2012-03-08 21:00:57 -05:00
parent 998891e734
commit 97b15e6fb0

View File

@ -976,25 +976,25 @@ test_util_strmisc(void)
} }
/* Test strcmp_opt */ /* Test strcmp_opt */
test_eq(-1, strcmp_opt("", "foo")); tt_int_op(strcmp_opt("", "foo"), <, 0);
test_eq(0, strcmp_opt("", "")); tt_int_op(strcmp_opt("", ""), ==, 0);
test_eq(1, strcmp_opt("foo", "")); tt_int_op(strcmp_opt("foo", ""), >, 0);
test_eq(-1, strcmp_opt(NULL, "")); tt_int_op(strcmp_opt(NULL, ""), <, 0);
test_eq(0, strcmp_opt(NULL, NULL)); tt_int_op(strcmp_opt(NULL, NULL), ==, 0);
test_eq(1, strcmp_opt("", NULL)); tt_int_op(strcmp_opt("", NULL), >, 0);
test_eq(-1, strcmp_opt(NULL, "foo")); tt_int_op(strcmp_opt(NULL, "foo"), <, 0);
test_eq(1, strcmp_opt("foo", NULL)); tt_int_op(strcmp_opt("foo", NULL), >, 0);
/* Test strcmp_len */ /* Test strcmp_len */
test_eq(1, strcmp_len("foo", "bar", 3)); tt_int_op(strcmp_len("foo", "bar", 3), >, 0);
test_eq(-1, strcmp_len("foo", "bar", 2)); /* First len, then lexical */ tt_int_op(strcmp_len("foo", "bar", 2), <, 0); /* First len, then lexical */
test_eq(1, strcmp_len("foo2", "foo1", 4)); tt_int_op(strcmp_len("foo2", "foo1", 4), >, 0);
test_eq(-1, strcmp_len("foo2", "foo1", 3)); /* Really stop at len */ tt_int_op(strcmp_len("foo2", "foo1", 3), <, 0); /* Really stop at len */
test_eq(0, strcmp_len("foo2", "foo", 3)); /* Really stop at len */ tt_int_op(strcmp_len("foo2", "foo", 3), ==, 0); /* Really stop at len */
test_eq(1, strcmp_len("blah", "", 4)); tt_int_op(strcmp_len("blah", "", 4), >, 0);
test_eq(0, strcmp_len("blah", "", 0)); tt_int_op(strcmp_len("blah", "", 0), ==, 0);
done: done:
; ;