diff options
author | overcaffeinated <overcaffeinated@airmail.cc> | 2016-11-03 20:52:11 +0000 |
---|---|---|
committer | overcaffeinated <overcaffeinated@airmail.cc> | 2016-11-03 20:52:11 +0000 |
commit | c613446ca2fa0d81fcf1f3169a2a6caa8e7a8ba3 (patch) | |
tree | d50b62020f6912098e48f0710ee19773706b68a3 | |
parent | c4603233db965262721a1481bb55f1cc508b48d5 (diff) | |
download | tor-c613446ca2fa0d81fcf1f3169a2a6caa8e7a8ba3.tar.gz tor-c613446ca2fa0d81fcf1f3169a2a6caa8e7a8ba3.zip |
Refactor tests for tor_htonll and tor_ntohll
Following kind feedback from dgoulet: add tests for min (0) and
max (UINT64_MAX) values. Rename expected results to something more
sensible than 'n'.
-rw-r--r-- | src/test/test_util.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index ea6e946041..b74f658146 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -5616,14 +5616,23 @@ static void test_util_htonll(void *arg) { (void)arg; - const uint64_t n = 0x1122334455667788; +#ifdef WORDS_BIGENDIAN + const uint64_t res_be = 0x8877665544332211; +#else + const uint64_t res_le = 0x1122334455667788; +#endif + + tt_u64_op(0, OP_EQ, tor_htonll(0)); + tt_u64_op(0, OP_EQ, tor_ntohll(0)); + tt_u64_op(UINT64_MAX, OP_EQ, tor_htonll(UINT64_MAX)); + tt_u64_op(UINT64_MAX, OP_EQ, tor_ntohll(UINT64_MAX)); #ifdef WORDS_BIGENDIAN - tt_u64_op(tor_htonll(n), OP_EQ, n); - tt_u64_op(tor_ntohll(0x8877665544332211), OP_EQ, 0x8877665544332211); + tt_u64_op(res_be, OP_EQ, tor_htonll(0x8877665544332211)); + tt_u64_op(res_be, OP_EQ, tor_ntohll(0x8877665544332211)); #else - tt_u64_op(tor_htonll(n), OP_EQ, 0x8877665544332211); - tt_u64_op(tor_ntohll(0x8877665544332211), OP_EQ, n); + tt_u64_op(res_le, OP_EQ, tor_htonll(0x8877665544332211)); + tt_u64_op(res_le, OP_EQ, tor_ntohll(0x8877665544332211)); #endif done: |