diff options
author | George Kadianakis <desnacked@riseup.net> | 2019-01-10 13:03:41 +0200 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2019-01-10 13:06:08 +0200 |
commit | 4db9c3d63e93912a82eabeb8a9fb851d5196c3c8 (patch) | |
tree | e0dab40813bb65d0b1ebf2fcd034a6b084147aaf /src | |
parent | e0e0338dc42ed786979759d56e0b65f129a5df8c (diff) | |
download | tor-4db9c3d63e93912a82eabeb8a9fb851d5196c3c8.tar.gz tor-4db9c3d63e93912a82eabeb8a9fb851d5196c3c8.zip |
Unittest for tor_isinf().
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test_util.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index bf64cff7ef..e8233d9d30 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -70,6 +70,28 @@ #define INFINITY_DBL ((double)INFINITY) #define NAN_DBL ((double)NAN) +/** Test the tor_isinf() wrapper */ +static void +test_tor_isinf(void *arg) +{ + (void) arg; + + tt_assert(tor_isinf(INFINITY_DBL)); + + tt_assert(!tor_isinf(NAN_DBL)); + tt_assert(!tor_isinf(DBL_EPSILON)); + tt_assert(!tor_isinf(DBL_MAX)); + tt_assert(!tor_isinf(DBL_MIN)); + + tt_assert(!tor_isinf(0.0)); + tt_assert(!tor_isinf(0.1)); + tt_assert(!tor_isinf(3)); + tt_assert(!tor_isinf(3.14)); + + done: + ; +} + /* XXXX this is a minimal wrapper to make the unit tests compile with the * changed tor_timegm interface. */ static time_t @@ -6191,6 +6213,7 @@ struct testcase_t util_tests[] = { UTIL_TEST(mathlog, 0), UTIL_TEST(fraction, 0), UTIL_TEST(weak_random, 0), + { "tor_isinf", test_tor_isinf, TT_FORK, NULL, NULL }, { "socket_ipv4", test_util_socket, TT_FORK, &passthrough_setup, (void*)"4" }, { "socket_ipv6", test_util_socket, TT_FORK, |