summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaron Keren <yaron.keren@gmail.com>2015-04-22 18:49:59 +0000
committerYaron Keren <yaron.keren@gmail.com>2015-04-22 18:49:59 +0000
commit2adb40ecb690c3c647bb9996577d823929f39e1e (patch)
tree992f1f7e737d4faf99f29adecda9a88235471642
parent3c55df1e842cd94491eec91c152157902e57582e (diff)
Another test to exercise APInt divide step D6.
This is divrem_big7 since divrem_big6 is used in Pawel upcoming patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235536 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--unittests/ADT/APIntTest.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/unittests/ADT/APIntTest.cpp b/unittests/ADT/APIntTest.cpp
index acdc1ecbbd..a8fc3629cd 100644
--- a/unittests/ADT/APIntTest.cpp
+++ b/unittests/ADT/APIntTest.cpp
@@ -409,6 +409,19 @@ TEST(APIntTest, divrem_big5) {
EXPECT_EQ(r, c);
}
+TEST(APIntTest, divrem_big7) {
+ // Yet another test for KnuthDiv rare step D6.
+ APInt a{224, "800000008000000200000005", 16};
+ APInt b{224, "fffffffd", 16};
+ APInt c{224, "80000000800000010000000f", 16};
+
+ auto p = a * b + c;
+ auto q = p.udiv(a);
+ auto r = p.urem(a);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+}
+
TEST(APIntTest, fromString) {
EXPECT_EQ(APInt(32, 0), APInt(32, "0", 2));
EXPECT_EQ(APInt(32, 1), APInt(32, "1", 2));