[PATCH] D34939: MathExtras UnitTest: Assert that isPowerOf2(0) is false. NFC.
Zvi Rackover via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 3 07:34:19 PDT 2017
zvi created this revision.
This is a follow-up on https://reviews.llvm.org/D34077. Elena observed that the
correctness of the code relies on isPowerOf2(0) returning false.
Adding a test to cover this corner-case.
https://reviews.llvm.org/D34939
Files:
unittests/Support/MathExtrasTest.cpp
Index: unittests/Support/MathExtrasTest.cpp
===================================================================
--- unittests/Support/MathExtrasTest.cpp
+++ unittests/Support/MathExtrasTest.cpp
@@ -177,13 +177,15 @@
}
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));
EXPECT_FALSE(isPowerOf2_32(0xABCDEF0));
}
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));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34939.105050.patch
Type: text/x-patch
Size: 668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170703/753956df/attachment-0001.bin>
More information about the llvm-commits
mailing list