[or-cvs] Turn tor_strpartion into a swiss-army-knife function, so it...

Nick Mathewson nickm at seul.org
Thu Oct 7 21:37:08 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv20169/src/or

Modified Files:
	test.c 
Log Message:
Turn tor_strpartion into a swiss-army-knife function, so it can terminate or not-terminate appropriately.

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -d -r1.120 -r1.121
--- test.c	7 Oct 2004 21:10:40 -0000	1.120
+++ test.c	7 Oct 2004 21:37:06 -0000	1.121
@@ -620,10 +620,18 @@
   test_streq(buf, "Testing123");
 
   /* Test tor_strpartition() */
-  test_assert(! tor_strpartition(buf, sizeof(buf), "abcdefg", "##", 3));
+  test_assert(! tor_strpartition(buf, sizeof(buf), "abcdefg", "##", 3,
+                                 TERMINATE_IF_EVEN));
   test_streq(buf, "abc##def##g");
-  test_assert(! tor_strpartition(buf, sizeof(buf), "abcdefghi", "##", 3));
+  test_assert(! tor_strpartition(buf, sizeof(buf), "abcdefg", "##", 3,
+                                 ALWAYS_TERMINATE));
+  test_streq(buf, "abc##def##g##");
+  test_assert(! tor_strpartition(buf, sizeof(buf), "abcdefghi", "##", 3,
+                                 TERMINATE_IF_EVEN));
   test_streq(buf, "abc##def##ghi##");
+  test_assert(! tor_strpartition(buf, sizeof(buf), "abcdefghi", "##", 3,
+                                 NEVER_TERMINATE));
+  test_streq(buf, "abc##def##ghi");
 
   /* XXXX test older functions. */
   smartlist_free(sl);
@@ -915,7 +923,7 @@
   strcat(buf2, "\n"
          "published 1970-01-01 00:00:00\n"
          "opt fingerprint ");
-  crypto_pk_get_fingerprint(pk2, fingerprint, 1);
+  test_assert(!crypto_pk_get_fingerprint(pk2, fingerprint, 1));
   strcat(buf2, fingerprint);
   strcat(buf2, "\nopt uptime 0\n"
   /* XXX the "0" above is hardcoded, but even if we made it reflect



More information about the tor-commits mailing list