summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/MathExtrasTest.cpp
diff options
context:
space:
mode:
authorZvi Rackover <zvi.rackover@intel.com>2017-07-03 18:42:47 +0000
committerZvi Rackover <zvi.rackover@intel.com>2017-07-03 18:42:47 +0000
commitfa00e34b8840414d43fad6883347b1b4d39bdd16 (patch)
tree5558357217b91b220541616c8469420216f439a8 /llvm/unittests/Support/MathExtrasTest.cpp
parentba80b8d437b63bffd48d5013ebf9d5f22ff85f12 (diff)
downloadbcm5719-llvm-fa00e34b8840414d43fad6883347b1b4d39bdd16.tar.gz
bcm5719-llvm-fa00e34b8840414d43fad6883347b1b4d39bdd16.zip
MathExtras UnitTest: Assert that isPowerOf2(0) is false. NFC.
Summary: This is a follow-up on D34077. Elena observed that the correctness of the code relies on isPowerOf2(0) returning false. Adding a test to cover this corner-case. Reviewers: delena, davide, craig.topper Reviewed By: davide Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34939 llvm-svn: 307046
Diffstat (limited to 'llvm/unittests/Support/MathExtrasTest.cpp')
-rw-r--r--llvm/unittests/Support/MathExtrasTest.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/unittests/Support/MathExtrasTest.cpp b/llvm/unittests/Support/MathExtrasTest.cpp
index e26653b8a65..694a1f24d03 100644
--- a/llvm/unittests/Support/MathExtrasTest.cpp
+++ b/llvm/unittests/Support/MathExtrasTest.cpp
@@ -177,6 +177,7 @@ TEST(MathExtras, reverseBits) {
}
TEST(MathExtras, isPowerOf2_32) {
+ EXPECT_FALSE(isPowerOf2_32(0));
EXPECT_TRUE(isPowerOf2_32(1 << 6));
EXPECT_TRUE(isPowerOf2_32(1 << 12));
EXPECT_FALSE(isPowerOf2_32((1 << 19) + 3));
@@ -184,6 +185,7 @@ TEST(MathExtras, isPowerOf2_32) {
}
TEST(MathExtras, isPowerOf2_64) {
+ EXPECT_FALSE(isPowerOf2_64(0));
EXPECT_TRUE(isPowerOf2_64(1LL << 46));
EXPECT_TRUE(isPowerOf2_64(1LL << 12));
EXPECT_FALSE(isPowerOf2_64((1LL << 53) + 3));
OpenPOWER on IntegriCloud