mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
APInt: update asserts for base-36
Hexatridecimal was added in r139695. And fix the unittest that now triggers the assert. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146754 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f9aabb8f32
commit
efb0d1e42f
@ -2189,7 +2189,7 @@ void APInt::toString(SmallVectorImpl<char> &Str, unsigned Radix,
|
|||||||
bool Signed, bool formatAsCLiteral) const {
|
bool Signed, bool formatAsCLiteral) const {
|
||||||
assert((Radix == 10 || Radix == 8 || Radix == 16 || Radix == 2 ||
|
assert((Radix == 10 || Radix == 8 || Radix == 16 || Radix == 2 ||
|
||||||
Radix == 36) &&
|
Radix == 36) &&
|
||||||
"Radix should be 2, 8, 10, or 16!");
|
"Radix should be 2, 8, 10, 16, or 36!");
|
||||||
|
|
||||||
const char *Prefix = "";
|
const char *Prefix = "";
|
||||||
if (formatAsCLiteral) {
|
if (formatAsCLiteral) {
|
||||||
@ -2202,9 +2202,13 @@ void APInt::toString(SmallVectorImpl<char> &Str, unsigned Radix,
|
|||||||
case 8:
|
case 8:
|
||||||
Prefix = "0";
|
Prefix = "0";
|
||||||
break;
|
break;
|
||||||
|
case 10:
|
||||||
|
break; // No prefix
|
||||||
case 16:
|
case 16:
|
||||||
Prefix = "0x";
|
Prefix = "0x";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
llvm_unreachable("Invalid radix!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ TEST(APIntTest, toString) {
|
|||||||
APInt(8, 0).toString(S, 16, true, true);
|
APInt(8, 0).toString(S, 16, true, true);
|
||||||
EXPECT_EQ(S.str().str(), "0x0");
|
EXPECT_EQ(S.str().str(), "0x0");
|
||||||
S.clear();
|
S.clear();
|
||||||
APInt(8, 0).toString(S, 36, true, true);
|
APInt(8, 0).toString(S, 36, true, false);
|
||||||
EXPECT_EQ(S.str().str(), "0");
|
EXPECT_EQ(S.str().str(), "0");
|
||||||
S.clear();
|
S.clear();
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ TEST(APIntTest, toString) {
|
|||||||
APInt(8, 255, isSigned).toString(S, 16, isSigned, true);
|
APInt(8, 255, isSigned).toString(S, 16, isSigned, true);
|
||||||
EXPECT_EQ(S.str().str(), "0xFF");
|
EXPECT_EQ(S.str().str(), "0xFF");
|
||||||
S.clear();
|
S.clear();
|
||||||
APInt(8, 255, isSigned).toString(S, 36, isSigned, true);
|
APInt(8, 255, isSigned).toString(S, 36, isSigned, false);
|
||||||
EXPECT_EQ(S.str().str(), "73");
|
EXPECT_EQ(S.str().str(), "73");
|
||||||
S.clear();
|
S.clear();
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ TEST(APIntTest, toString) {
|
|||||||
APInt(8, 255, isSigned).toString(S, 16, isSigned, true);
|
APInt(8, 255, isSigned).toString(S, 16, isSigned, true);
|
||||||
EXPECT_EQ(S.str().str(), "-0x1");
|
EXPECT_EQ(S.str().str(), "-0x1");
|
||||||
S.clear();
|
S.clear();
|
||||||
APInt(8, 255, isSigned).toString(S, 36, isSigned, true);
|
APInt(8, 255, isSigned).toString(S, 36, isSigned, false);
|
||||||
EXPECT_EQ(S.str().str(), "-1");
|
EXPECT_EQ(S.str().str(), "-1");
|
||||||
S.clear();
|
S.clear();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user