aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Sundman <anders@4zm.org>2011-10-31 23:36:35 +0100
committerAnders Sundman <anders@4zm.org>2011-11-10 23:26:29 +0100
commitfa9aef6eec699f2c9c913467ea3032205d1a2a73 (patch)
tree26057c6602e908fdf63d930e621fe006d45634d4
parentf0589da0e3270e627ac6fd249976234a4c085d3f (diff)
downloadtor-fa9aef6eec699f2c9c913467ea3032205d1a2a73.tar.gz
tor-fa9aef6eec699f2c9c913467ea3032205d1a2a73.zip
Unit test for hex_str func
Note: Too long input is undefined by contract. That behaviour should not be asserted in test.
-rw-r--r--src/test/test_util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 6603ab00d3..e9240e1d9a 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -409,6 +409,20 @@ test_util_strmisc(void)
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
smartlist_free(sl);
}
+
+ /* Test hex_str */
+ {
+ char binary_data[64];
+ size_t i;
+ for (i = 0; i < sizeof(binary_data); ++i)
+ binary_data[i] = i;
+ test_streq(hex_str(binary_data, 0), "");
+ test_streq(hex_str(binary_data, 1), "00");
+ test_streq(hex_str(binary_data, 17), "000102030405060708090A0B0C0D0E0F10");
+ test_streq(hex_str(binary_data, 32),
+ "000102030405060708090A0B0C0D0E0F"
+ "101112131415161718191A1B1C1D1E1F");
+ }
done:
;
}