Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(362)

Unified Diff: unittests/ADT/APIntTest.cpp

Issue 4769041: [PATCH] Add APInt::getSigned(bits, value)
Patch Set: Fixes Created 13 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « unittests/ADT/APFloatTest.cpp ('k') | unittests/Support/ConstantRangeTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: unittests/ADT/APIntTest.cpp
diff --git a/unittests/ADT/APIntTest.cpp b/unittests/ADT/APIntTest.cpp
index c9b3bc51c135f45f53d845fd55be484ae5e95624..06e687f650eddb439958aa1bd4f7c962f714d101 100644
--- a/unittests/ADT/APIntTest.cpp
+++ b/unittests/ADT/APIntTest.cpp
@@ -25,11 +25,11 @@ TEST(APIntTest, ShiftLeftByZero) {
}
TEST(APIntTest, i128_NegativeCount) {
- APInt Minus3(128, static_cast<uint64_t>(-3), true);
+ APInt Minus3 = APInt::getSigned(128, -3);
EXPECT_EQ(126u, Minus3.countLeadingOnes());
EXPECT_EQ(-3, Minus3.getSExtValue());
- APInt Minus1(128, static_cast<uint64_t>(-1), true);
+ APInt Minus1 = APInt::getSigned(128, -1);
EXPECT_EQ(0u, Minus1.countLeadingZeros());
EXPECT_EQ(128u, Minus1.countLeadingOnes());
EXPECT_EQ(128u, Minus1.getActiveBits());
@@ -43,7 +43,7 @@ TEST(APIntTest, i128_NegativeCount) {
#if defined(__llvm__) || !defined(__FreeBSD__)
TEST(APIntTest, i33_Count) {
- APInt i33minus2(33, static_cast<uint64_t>(-2), true);
+ APInt i33minus2 = APInt::getSigned(33, -2);
EXPECT_EQ(0u, i33minus2.countLeadingZeros());
EXPECT_EQ(32u, i33minus2.countLeadingOnes());
EXPECT_EQ(33u, i33minus2.getActiveBits());
@@ -56,7 +56,7 @@ TEST(APIntTest, i33_Count) {
#endif
TEST(APIntTest, i65_Count) {
- APInt i65minus(65, 0, true);
+ APInt i65minus(65, 0);
i65minus.setBit(64);
EXPECT_EQ(0u, i65minus.countLeadingZeros());
EXPECT_EQ(1u, i65minus.countLeadingOnes());
@@ -74,7 +74,7 @@ TEST(APIntTest, i128_PositiveCount) {
EXPECT_EQ(128u, u128max.countTrailingOnes());
EXPECT_EQ(128u, u128max.countPopulation());
- APInt u64max(128, static_cast<uint64_t>(-1), false);
+ APInt u64max(128, static_cast<uint64_t>(-1));
EXPECT_EQ(64u, u64max.countLeadingZeros());
EXPECT_EQ(0u, u64max.countLeadingOnes());
EXPECT_EQ(64u, u64max.getActiveBits());
@@ -83,7 +83,7 @@ TEST(APIntTest, i128_PositiveCount) {
EXPECT_EQ(64u, u64max.countPopulation());
EXPECT_EQ((uint64_t)~0ull, u64max.getZExtValue());
- APInt zero(128, 0, true);
+ APInt zero(128, 0);
EXPECT_EQ(128u, zero.countLeadingZeros());
EXPECT_EQ(0u, zero.countLeadingOnes());
EXPECT_EQ(0u, zero.getActiveBits());
@@ -93,7 +93,7 @@ TEST(APIntTest, i128_PositiveCount) {
EXPECT_EQ(0u, zero.getSExtValue());
EXPECT_EQ(0u, zero.getZExtValue());
- APInt one(128, 1, true);
+ APInt one = APInt::getSigned(128, 1);
EXPECT_EQ(127u, one.countLeadingZeros());
EXPECT_EQ(0u, one.countLeadingOnes());
EXPECT_EQ(1u, one.getActiveBits());
@@ -105,8 +105,8 @@ TEST(APIntTest, i128_PositiveCount) {
}
TEST(APIntTest, i1) {
- const APInt neg_two(1, static_cast<uint64_t>(-2), true);
- const APInt neg_one(1, static_cast<uint64_t>(-1), true);
+ const APInt neg_two = APInt::getSigned(1, -2);
+ const APInt neg_one = APInt::getSigned(1, -1);
const APInt zero(1, 0);
const APInt one(1, 1);
const APInt two(1, 2);
@@ -342,30 +342,30 @@ TEST(APIntTest, toString) {
S.clear();
isSigned = false;
- APInt(8, 255, isSigned).toString(S, 2, isSigned, true);
+ APInt(8, 255).toString(S, 2, isSigned, true);
EXPECT_EQ(S.str().str(), "0b11111111");
S.clear();
- APInt(8, 255, isSigned).toString(S, 8, isSigned, true);
+ APInt(8, 255).toString(S, 8, isSigned, true);
EXPECT_EQ(S.str().str(), "0377");
S.clear();
- APInt(8, 255, isSigned).toString(S, 10, isSigned, true);
+ APInt(8, 255).toString(S, 10, isSigned, true);
EXPECT_EQ(S.str().str(), "255");
S.clear();
- APInt(8, 255, isSigned).toString(S, 16, isSigned, true);
+ APInt(8, 255).toString(S, 16, isSigned, true);
EXPECT_EQ(S.str().str(), "0xFF");
S.clear();
isSigned = true;
- APInt(8, 255, isSigned).toString(S, 2, isSigned, true);
+ APInt::getSigned(8, 255).toString(S, 2, isSigned, true);
EXPECT_EQ(S.str().str(), "-0b1");
S.clear();
- APInt(8, 255, isSigned).toString(S, 8, isSigned, true);
+ APInt::getSigned(8, 255).toString(S, 8, isSigned, true);
EXPECT_EQ(S.str().str(), "-01");
S.clear();
- APInt(8, 255, isSigned).toString(S, 10, isSigned, true);
+ APInt::getSigned(8, 255).toString(S, 10, isSigned, true);
EXPECT_EQ(S.str().str(), "-1");
S.clear();
- APInt(8, 255, isSigned).toString(S, 16, isSigned, true);
+ APInt::getSigned(8, 255).toString(S, 16, isSigned, true);
EXPECT_EQ(S.str().str(), "-0x1");
S.clear();
}
« no previous file with comments | « unittests/ADT/APFloatTest.cpp ('k') | unittests/Support/ConstantRangeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b