[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r9678: Add unit tests for tor_parse_uint64 (in tor/trunk: . src/or)



Author: nickm
Date: 2007-02-28 11:56:28 -0500 (Wed, 28 Feb 2007)
New Revision: 9678

Modified:
   tor/trunk/
   tor/trunk/src/or/test.c
Log:
 r11982@catbus:  nickm | 2007-02-28 11:55:41 -0500
 Add unit tests for tor_parse_uint64



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11982] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2007-02-28 16:56:07 UTC (rev 9677)
+++ tor/trunk/src/or/test.c	2007-02-28 16:56:28 UTC (rev 9678)
@@ -695,6 +695,18 @@
   test_eq(10L, tor_parse_long("10",10,0,100,NULL,NULL));
   test_eq(0L, tor_parse_long("10",10,50,100,NULL,NULL));
 
+  /* Test tor_parse_uint64. */
+  test_assert(U64_LITERAL(10) == tor_parse_uint64("10 x",10,0,100, &i, &cp));
+  test_assert(i == 1);
+  test_streq(cp, " x");
+  test_assert(U64_LITERAL(12345678901) ==
+              tor_parse_uint64("12345678901",10,0,UINT64_MAX, &i, &cp));
+  test_assert(i == 1);
+  test_streq(cp, "");
+  test_assert(U64_LITERAL(0) ==
+              tor_parse_uint64("12345678901",10,500,INT32_MAX, &i, &cp));
+  test_assert(i == 0);
+
   /* Test parse_line_from_str */
   strlcpy(buf, "k v\n" " key    value with spaces   \n" "keykey val\n"
           "k2\n"