mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Add APInt support for converting to/from hexatridecimal strings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139695 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -237,6 +237,20 @@ TEST(APIntTest, fromString) {
|
||||
EXPECT_EQ(APInt(32, uint64_t(-16LL)), APInt(32, "-10", 16));
|
||||
EXPECT_EQ(APInt(32, uint64_t(-31LL)), APInt(32, "-1F", 16));
|
||||
EXPECT_EQ(APInt(32, uint64_t(-32LL)), APInt(32, "-20", 16));
|
||||
|
||||
EXPECT_EQ(APInt(32, 0), APInt(32, "0", 36));
|
||||
EXPECT_EQ(APInt(32, 1), APInt(32, "1", 36));
|
||||
EXPECT_EQ(APInt(32, 35), APInt(32, "Z", 36));
|
||||
EXPECT_EQ(APInt(32, 36), APInt(32, "10", 36));
|
||||
EXPECT_EQ(APInt(32, 71), APInt(32, "1Z", 36));
|
||||
EXPECT_EQ(APInt(32, 72), APInt(32, "20", 36));
|
||||
|
||||
EXPECT_EQ(APInt(32, uint64_t(-0LL)), APInt(32, "-0", 36));
|
||||
EXPECT_EQ(APInt(32, uint64_t(-1LL)), APInt(32, "-1", 36));
|
||||
EXPECT_EQ(APInt(32, uint64_t(-35LL)), APInt(32, "-Z", 36));
|
||||
EXPECT_EQ(APInt(32, uint64_t(-36LL)), APInt(32, "-10", 36));
|
||||
EXPECT_EQ(APInt(32, uint64_t(-71LL)), APInt(32, "-1Z", 36));
|
||||
EXPECT_EQ(APInt(32, uint64_t(-72LL)), APInt(32, "-20", 36));
|
||||
}
|
||||
|
||||
TEST(APIntTest, FromArray) {
|
||||
@@ -340,6 +354,9 @@ TEST(APIntTest, toString) {
|
||||
APInt(8, 0).toString(S, 16, true, true);
|
||||
EXPECT_EQ(S.str().str(), "0x0");
|
||||
S.clear();
|
||||
APInt(8, 0).toString(S, 36, true, true);
|
||||
EXPECT_EQ(S.str().str(), "0");
|
||||
S.clear();
|
||||
|
||||
isSigned = false;
|
||||
APInt(8, 255, isSigned).toString(S, 2, isSigned, true);
|
||||
@@ -354,6 +371,9 @@ TEST(APIntTest, toString) {
|
||||
APInt(8, 255, isSigned).toString(S, 16, isSigned, true);
|
||||
EXPECT_EQ(S.str().str(), "0xFF");
|
||||
S.clear();
|
||||
APInt(8, 255, isSigned).toString(S, 36, isSigned, true);
|
||||
EXPECT_EQ(S.str().str(), "73");
|
||||
S.clear();
|
||||
|
||||
isSigned = true;
|
||||
APInt(8, 255, isSigned).toString(S, 2, isSigned, true);
|
||||
@@ -368,6 +388,9 @@ TEST(APIntTest, toString) {
|
||||
APInt(8, 255, isSigned).toString(S, 16, isSigned, true);
|
||||
EXPECT_EQ(S.str().str(), "-0x1");
|
||||
S.clear();
|
||||
APInt(8, 255, isSigned).toString(S, 36, isSigned, true);
|
||||
EXPECT_EQ(S.str().str(), "-1");
|
||||
S.clear();
|
||||
}
|
||||
|
||||
TEST(APIntTest, Log2) {
|
||||
@@ -407,7 +430,7 @@ TEST(APIntTest, magicu) {
|
||||
TEST(APIntTest, StringDeath) {
|
||||
EXPECT_DEATH(APInt(0, "", 0), "Bitwidth too small");
|
||||
EXPECT_DEATH(APInt(32, "", 0), "Invalid string length");
|
||||
EXPECT_DEATH(APInt(32, "0", 0), "Radix should be 2, 8, 10, or 16!");
|
||||
EXPECT_DEATH(APInt(32, "0", 0), "Radix should be 2, 8, 10, 16, or 36!");
|
||||
EXPECT_DEATH(APInt(32, "", 10), "Invalid string length");
|
||||
EXPECT_DEATH(APInt(32, "-", 10), "String is only a sign, needs a value.");
|
||||
EXPECT_DEATH(APInt(1, "1234", 10), "Insufficient bit width");
|
||||
|
Reference in New Issue
Block a user