diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-01-14 14:48:00 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-01-14 14:48:00 -0500 |
commit | b169c8c14f23394b40305f38ee4ce08add278e27 (patch) | |
tree | 0649da16a97792103773f9d5cedbfd75deac49bd /src/test/test_util.c | |
parent | 691dec5d4615dec9a845d0f7dea7ef55cc66fe62 (diff) | |
parent | b269ab5aaeee65a3a0b1e5e0923d9dc7898c232e (diff) | |
download | tor-b169c8c14f23394b40305f38ee4ce08add278e27.tar.gz tor-b169c8c14f23394b40305f38ee4ce08add278e27.zip |
Merge remote-tracking branch 'asn-github/adaptive_padding-final'
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 5ffe2d6b1a..2fd9d24498 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -19,6 +19,7 @@ #include "feature/client/transports.h" #include "lib/crypt_ops/crypto_format.h" #include "lib/crypt_ops/crypto_rand.h" +#include "lib/defs/time.h" #include "test/test.h" #include "lib/memarea/memarea.h" #include "lib/process/waitpid.h" @@ -69,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 @@ -404,7 +427,6 @@ test_util_time(void *arg) /* Assume tv_usec is an unsigned integer until proven otherwise */ #define TV_USEC_MAX UINT_MAX -#define TOR_USEC_PER_SEC 1000000 /* Overflows in the result type */ @@ -6182,6 +6204,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, |