]> granicus.if.org Git - libevent/commitdiff
Move util tests to regress_util.c
authorNick Mathewson <nickm@torproject.org>
Fri, 30 Jan 2009 17:43:59 +0000 (17:43 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 30 Jan 2009 17:43:59 +0000 (17:43 +0000)
svn:r1075

test/regress.c
test/regress_util.c

index ee348aba8cfe9fd204bc55c8e1ca3ff1c5c37e03..c0b83a607fc145c643763cf51bab2d51ffd133d7 100644 (file)
@@ -2274,39 +2274,6 @@ rpc_test(void)
 #endif
 }
 
-static void
-test_evutil_strtoll(void *ptr)
-{
-        const char *s;
-        char *endptr;
-
-        tt_want(evutil_strtoll("5000000000", NULL, 10) ==
-               ((ev_int64_t)5000000)*1000);
-        tt_want(evutil_strtoll("-5000000000", NULL, 10) ==
-               ((ev_int64_t)5000000)*-1000);
-       s = " 99999stuff";
-       tt_want(evutil_strtoll(s, &endptr, 10) == (ev_int64_t)99999);
-       tt_want(endptr == s+6);
-       tt_want(evutil_strtoll("foo", NULL, 10) == 0);
- }
-
-static void
-test_evutil_snprintf(void *ptr)
-{
-       char buf[16];
-       int r;
-       r = evutil_snprintf(buf, sizeof(buf), "%d %d", 50, 100);
-        tt_str_op(buf, ==, "50 100");
-        tt_int_op(r, ==, 6);
-
-       r = evutil_snprintf(buf, sizeof(buf), "longish %d", 1234567890);
-        tt_str_op(buf, ==, "longish 1234567");
-        tt_int_op(r, ==, 18);
-
-      end:
-       ;
-}
-
 static void
 test_methods(void *ptr)
 {
@@ -2353,10 +2320,8 @@ end:
 struct testcase_t legacy_testcases[] = {
         /* Some converted-over tests */
         { "methods", test_methods, TT_FORK, NULL, NULL },
-       { "evutil_snprintf", test_evutil_snprintf, 0, NULL, NULL },
 
         /* These are still using the old API */
-        { "evutil_strtoll", test_evutil_strtoll, 0, NULL, NULL },
         LEGACY(persistent_timeout, TT_FORK|TT_NEED_BASE),
         LEGACY(priorities, TT_FORK|TT_NEED_BASE),
 
index 2f604100a7ca75855e3dd2c672342a07596bee5d..bdb08506f6afe6c382db52773517a4c1e19a7d11 100644 (file)
@@ -260,10 +260,45 @@ regress_sockaddr_port_parse(void *ptr)
        }
 }
 
+static void
+test_evutil_strtoll(void *ptr)
+{
+        const char *s;
+        char *endptr;
+
+        tt_want(evutil_strtoll("5000000000", NULL, 10) ==
+               ((ev_int64_t)5000000)*1000);
+        tt_want(evutil_strtoll("-5000000000", NULL, 10) ==
+               ((ev_int64_t)5000000)*-1000);
+       s = " 99999stuff";
+       tt_want(evutil_strtoll(s, &endptr, 10) == (ev_int64_t)99999);
+       tt_want(endptr == s+6);
+       tt_want(evutil_strtoll("foo", NULL, 10) == 0);
+ }
+
+static void
+test_evutil_snprintf(void *ptr)
+{
+       char buf[16];
+       int r;
+       r = evutil_snprintf(buf, sizeof(buf), "%d %d", 50, 100);
+        tt_str_op(buf, ==, "50 100");
+        tt_int_op(r, ==, 6);
+
+       r = evutil_snprintf(buf, sizeof(buf), "longish %d", 1234567890);
+        tt_str_op(buf, ==, "longish 1234567");
+        tt_int_op(r, ==, 18);
+
+      end:
+       ;
+}
+
 struct testcase_t util_testcases[] = {
        { "ipv4_parse", regress_ipv4_parse, 0, NULL, NULL },
        { "ipv6_parse", regress_ipv6_parse, 0, NULL, NULL },
        { "sockaddr_port_parse", regress_sockaddr_port_parse, 0, NULL, NULL },
+       { "evutil_snprintf", test_evutil_snprintf, 0, NULL, NULL },
+       { "evutil_strtoll", test_evutil_strtoll, 0, NULL, NULL },
        END_OF_TESTCASES,
 };