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

nickm at torproject.org nickm at torproject.org
Fri Mar 9 16:30:59 UTC 2012


commit 97b15e6fb0a1cda39adfadfe9f9926b6cf35b136
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Mar 8 21:00:57 2012 -0500

    Fix new strcmp_opt/len tests on OSs where strcmp() can return values >1 or <-1
---
 src/test/test_util.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/test/test_util.c b/src/test/test_util.c
index 741b8d5..5bbf448 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -976,25 +976,25 @@ test_util_strmisc(void)
   }
 
   /* Test strcmp_opt */
-  test_eq(-1, strcmp_opt("",   "foo"));
-  test_eq(0,  strcmp_opt("",    ""));
-  test_eq(1,  strcmp_opt("foo", ""));
+  tt_int_op(strcmp_opt("",   "foo"), <, 0);
+  tt_int_op(strcmp_opt("",    ""),  ==, 0);
+  tt_int_op(strcmp_opt("foo", ""),   >, 0);
 
-  test_eq(-1, strcmp_opt(NULL,  ""));
-  test_eq(0,  strcmp_opt(NULL,  NULL));
-  test_eq(1,  strcmp_opt("",    NULL));
+  tt_int_op(strcmp_opt(NULL,  ""),    <, 0);
+  tt_int_op(strcmp_opt(NULL,  NULL), ==, 0);
+  tt_int_op(strcmp_opt("",    NULL),  >, 0);
 
-  test_eq(-1, strcmp_opt(NULL,  "foo"));
-  test_eq(1,  strcmp_opt("foo", NULL));
+  tt_int_op(strcmp_opt(NULL,  "foo"), <, 0);
+  tt_int_op(strcmp_opt("foo", NULL),  >, 0);
 
   /* Test strcmp_len */
-  test_eq(1,  strcmp_len("foo", "bar", 3));
-  test_eq(-1, strcmp_len("foo", "bar", 2)); /* First len, then lexical */
-  test_eq(1,  strcmp_len("foo2", "foo1", 4));
-  test_eq(-1, strcmp_len("foo2", "foo1", 3)); /* Really stop at len */
-  test_eq(0, strcmp_len("foo2", "foo", 3));   /* Really stop at len */
-  test_eq(1, strcmp_len("blah", "", 4));
-  test_eq(0, strcmp_len("blah", "", 0));
+  tt_int_op(strcmp_len("foo", "bar", 3),   >, 0);
+  tt_int_op(strcmp_len("foo", "bar", 2),   <, 0); /* First len, then lexical */
+  tt_int_op(strcmp_len("foo2", "foo1", 4), >, 0);
+  tt_int_op(strcmp_len("foo2", "foo1", 3), <, 0); /* Really stop at len */
+  tt_int_op(strcmp_len("foo2", "foo", 3), ==, 0);   /* Really stop at len */
+  tt_int_op(strcmp_len("blah", "", 4),     >, 0);
+  tt_int_op(strcmp_len("blah", "", 0),    ==, 0);
 
  done:
   ;





More information about the tor-commits mailing list