summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorCristian Rodríguez <crrodriguez@opensuse.org>2013-04-04 20:09:50 -0300
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-05 00:17:35 -0400
commit144e51eca20b72c8177314c225d8c15c1b0b9d6b (patch)
treee7cbe68e619a5cae506318edc7489469c61451fe /src/test
parente8853816bf197afc71819e28f1316a5d5ee4b4c3 (diff)
journal: u64log2 can be expressed just as __builtin_clzll(n) ^ 63U
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-util.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 08310c83ca..eaf7e22d0f 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -338,6 +338,16 @@ static void test_hostname_is_valid(void) {
assert(!hostname_is_valid("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"));
}
+static void test_u64log2(void) {
+ assert(u64log2(0) == 0);
+ assert(u64log2(8) == 3);
+ assert(u64log2(9) == 3);
+ assert(u64log2(15) == 3);
+ assert(u64log2(16) == 4);
+ assert(u64log2(1024*1024) == 20);
+ assert(u64log2(1024*1024+5) == 20);
+}
+
int main(int argc, char *argv[]) {
test_streq_ptr();
test_first_word();
@@ -363,6 +373,7 @@ int main(int argc, char *argv[]) {
test_memdup_multiply();
test_bus_path_escape();
test_hostname_is_valid();
+ test_u64log2();
return 0;
}