mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-23 14:25:07 +00:00
ADT: Add a string APSInt constructor.
This commit moves the APSInt initialization code that's used by the LLLexer class into a new APSInt constructor that constructs APSInts from strings. This change is useful for MIR Serialization, as it would allow the MILexer class to use the same APSInt initialization as LLexer when parsing immediate machine operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240436 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -143,4 +143,23 @@ TEST(APSIntTest, compareValues) {
|
||||
EXPECT_TRUE(APSInt::compareValues(U(8), S(-7).trunc(32)) > 0);
|
||||
}
|
||||
|
||||
TEST(APSIntTest, FromString) {
|
||||
EXPECT_EQ(APSInt("1").getExtValue(), 1);
|
||||
EXPECT_EQ(APSInt("-1").getExtValue(), -1);
|
||||
EXPECT_EQ(APSInt("0").getExtValue(), 0);
|
||||
EXPECT_EQ(APSInt("56789").getExtValue(), 56789);
|
||||
EXPECT_EQ(APSInt("-1234").getExtValue(), -1234);
|
||||
}
|
||||
|
||||
#ifdef GTEST_HAS_DEATH_TEST
|
||||
#ifndef NDEBUG
|
||||
|
||||
TEST(APSIntTest, StringDeath) {
|
||||
EXPECT_DEATH(APSInt(""), "Invalid string length");
|
||||
EXPECT_DEATH(APSInt("1a"), "Invalid character in digit string");
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} // end anonymous namespace
|
||||
|
Reference in New Issue
Block a user