summaryrefslogtreecommitdiff
path: root/unittests/ADT/APIntTest.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-05-08 17:12:57 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-05-08 17:12:57 +0000
commitc46e6a5940c50058e00c0c5f9123fd82e338d29a (patch)
tree89a719d723035c54a190b1f81d329834f1f93336 /unittests/ADT/APIntTest.cpp
parent148779df305667b6942fee7e758fdf81a6498f38 (diff)
Notes
Diffstat (limited to 'unittests/ADT/APIntTest.cpp')
-rw-r--r--unittests/ADT/APIntTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/unittests/ADT/APIntTest.cpp b/unittests/ADT/APIntTest.cpp
index bb6cf35fe9e4..5594955e7baf 100644
--- a/unittests/ADT/APIntTest.cpp
+++ b/unittests/ADT/APIntTest.cpp
@@ -2142,4 +2142,23 @@ TEST(APIntTest, sext) {
EXPECT_EQ(63U, i32_neg1.countPopulation());
}
+TEST(APIntTest, multiply) {
+ APInt i64(64, 1234);
+
+ EXPECT_EQ(7006652, i64 * 5678);
+ EXPECT_EQ(7006652, 5678 * i64);
+
+ APInt i128 = APInt::getOneBitSet(128, 64);
+ APInt i128_1234(128, 1234);
+ i128_1234 <<= 64;
+ EXPECT_EQ(i128_1234, i128 * 1234);
+ EXPECT_EQ(i128_1234, 1234 * i128);
+
+ APInt i96 = APInt::getOneBitSet(96, 64);
+ i96 *= ~0ULL;
+ EXPECT_EQ(32U, i96.countLeadingOnes());
+ EXPECT_EQ(32U, i96.countPopulation());
+ EXPECT_EQ(64U, i96.countTrailingZeros());
+}
+
} // end anonymous namespace