diff options
Diffstat (limited to 'llvm/unittests/Support/KnownBitsTest.cpp')
-rw-r--r-- | llvm/unittests/Support/KnownBitsTest.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/unittests/Support/KnownBitsTest.cpp b/llvm/unittests/Support/KnownBitsTest.cpp index c2b3b127cf1..372521dc5c9 100644 --- a/llvm/unittests/Support/KnownBitsTest.cpp +++ b/llvm/unittests/Support/KnownBitsTest.cpp @@ -127,4 +127,18 @@ TEST(KnownBitsTest, AddSubExhaustive) { TestAddSubExhaustive(false); } +TEST(KnownBitsTest, GetMinMaxVal) { + unsigned Bits = 4; + ForeachKnownBits(Bits, [&](const KnownBits &Known) { + APInt Min = APInt::getMaxValue(Bits); + APInt Max = APInt::getMinValue(Bits); + ForeachNumInKnownBits(Known, [&](const APInt &N) { + Min = APIntOps::umin(Min, N); + Max = APIntOps::umax(Max, N); + }); + EXPECT_EQ(Min, Known.getMinValue()); + EXPECT_EQ(Max, Known.getMaxValue()); + }); +} + } // end anonymous namespace |