aboutsummaryrefslogtreecommitdiff
path: root/src/test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test.cpp')
-rw-r--r--src/test.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/test.cpp b/src/test.cpp
index cd353c0ea..6cd7983fc 100644
--- a/src/test.cpp
+++ b/src/test.cpp
@@ -199,6 +199,16 @@ struct TestUtilities: public TestBase
UASSERT(is_number("123") == true);
UASSERT(is_number("") == false);
UASSERT(is_number("123a") == false);
+ UASSERT(is_power_of_two(0) == false);
+ UASSERT(is_power_of_two(1) == true);
+ UASSERT(is_power_of_two(2) == true);
+ UASSERT(is_power_of_two(3) == false);
+ for (int exponent = 2; exponent <= 31; ++exponent) {
+ UASSERT(is_power_of_two((1 << exponent) - 1) == false);
+ UASSERT(is_power_of_two((1 << exponent)) == true);
+ UASSERT(is_power_of_two((1 << exponent) + 1) == false);
+ }
+ UASSERT(is_power_of_two((u32)-1) == false);
}
};