[llvm] r307046 - MathExtras UnitTest: Assert that isPowerOf2(0) is false. NFC.

Zvi Rackover via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 3 11:42:47 PDT 2017


Author: zvi
Date: Mon Jul  3 11:42:47 2017
New Revision: 307046

URL: http://llvm.org/viewvc/llvm-project?rev=307046&view=rev
Log:
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

Modified:
    llvm/trunk/unittests/Support/MathExtrasTest.cpp

Modified: llvm/trunk/unittests/Support/MathExtrasTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/MathExtrasTest.cpp?rev=307046&r1=307045&r2=307046&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/MathExtrasTest.cpp (original)
+++ llvm/trunk/unittests/Support/MathExtrasTest.cpp Mon Jul  3 11:42:47 2017
@@ -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));




More information about the llvm-commits mailing list