summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Sundman <anders@4zm.org>2011-10-31 23:47:11 +0100
committerAnders Sundman <anders@4zm.org>2011-11-10 23:26:39 +0100
commitc0efd461d378974365e4b9a86c784db08e0c78f6 (patch)
tree9ed8cd249df4b14351c83055e0002acadbe1dba2
parentfa9aef6eec699f2c9c913467ea3032205d1a2a73 (diff)
downloadtor-c0efd461d378974365e4b9a86c784db08e0c78f6.tar.gz
tor-c0efd461d378974365e4b9a86c784db08e0c78f6.zip
Unit test for n_bits_set func
-rw-r--r--src/test/test_util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index e9240e1d9a..806ebb1d43 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -1752,6 +1752,21 @@ test_util_di_ops(void)
;
}
+/**
+ * Test counting high bits
+ */
+static void
+test_util_n_bits_set(void *ptr)
+{
+ (void)ptr;
+ test_eq(n_bits_set_u8(0), 0);
+ test_eq(n_bits_set_u8(1), 1);
+ test_eq(n_bits_set_u8(129), 2);
+ test_eq(n_bits_set_u8(255), 8);
+ done:
+ ;
+}
+
#define UTIL_LEGACY(name) \
{ #name, legacy_test_helper, 0, &legacy_setup, test_util_ ## name }
@@ -1789,6 +1804,7 @@ struct testcase_t util_tests[] = {
UTIL_TEST(spawn_background_partial_read, 0),
UTIL_TEST(join_win_cmdline, 0),
UTIL_TEST(split_lines, 0),
+ UTIL_TEST(n_bits_set, 0),
END_OF_TESTCASES
};