aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_util.c
diff options
context:
space:
mode:
authorovercaffeinated <overcaffeinated@airmail.cc>2016-11-03 19:37:59 +0000
committerovercaffeinated <overcaffeinated@airmail.cc>2016-11-03 19:37:59 +0000
commitc4603233db965262721a1481bb55f1cc508b48d5 (patch)
tree29bb15ebc663323499ed563ea05012342e5bd34a /src/test/test_util.c
parentf0b86e30d0d53e997872a9ece42242e8e14d45c8 (diff)
downloadtor-c4603233db965262721a1481bb55f1cc508b48d5.tar.gz
tor-c4603233db965262721a1481bb55f1cc508b48d5.zip
Add unit test for tor_htonll and tor_ntohll
Add tests for tor_htonll and tor_ntohll - fixes bug 19563.
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r--src/test/test_util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 7276c0cbfc..ea6e946041 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -5612,6 +5612,24 @@ test_util_monotonic_time_ratchet(void *arg)
;
}
+static void
+test_util_htonll(void *arg)
+{
+ (void)arg;
+ const uint64_t n = 0x1122334455667788;
+
+#ifdef WORDS_BIGENDIAN
+ tt_u64_op(tor_htonll(n), OP_EQ, n);
+ tt_u64_op(tor_ntohll(0x8877665544332211), OP_EQ, 0x8877665544332211);
+#else
+ tt_u64_op(tor_htonll(n), OP_EQ, 0x8877665544332211);
+ tt_u64_op(tor_ntohll(0x8877665544332211), OP_EQ, n);
+#endif
+
+ done:
+ ;
+}
+
#define UTIL_LEGACY(name) \
{ #name, test_util_ ## name , 0, NULL, NULL }
@@ -5705,6 +5723,7 @@ struct testcase_t util_tests[] = {
UTIL_TEST(calloc_check, 0),
UTIL_TEST(monotonic_time, 0),
UTIL_TEST(monotonic_time_ratchet, TT_FORK),
+ UTIL_TEST(htonll, 0),
END_OF_TESTCASES
};