aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/StringRefTest.cpp
diff options
context:
space:
mode:
authorThomas Preud'homme <thomas.preudhomme@arm.com>2023-05-16 09:24:57 +0000
committerThomas Preud'homme <thomas.preudhomme@arm.com>2023-05-23 14:01:38 +0100
commitdd00421c60716973f5d919967fd4d6ef84025979 (patch)
tree8bb59a9a7b1e2a497a71ccc0b01bedc8043e2414 /llvm/unittests/ADT/StringRefTest.cpp
parent1ff828c6c837055b1f773ac1271f3ce249a1b0e1 (diff)
downloadllvm-dd00421c60716973f5d919967fd4d6ef84025979.zip
llvm-dd00421c60716973f5d919967fd4d6ef84025979.tar.gz
llvm-dd00421c60716973f5d919967fd4d6ef84025979.tar.bz2
Add StringRef::consumeInteger(APInt)
This will be required to allow arbitrary precision support to FileCheck's numeric variables and expressions. Note: as per getAsInteger(), this does not support negative value. If there is interest for that it can be added in a separate patch. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D150878
Diffstat (limited to 'llvm/unittests/ADT/StringRefTest.cpp')
-rw-r--r--llvm/unittests/ADT/StringRefTest.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index cad1974..a208527 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -818,6 +818,7 @@ TEST(StringRefTest, consumeIntegerUnsigned) {
uint16_t U16;
uint32_t U32;
uint64_t U64;
+ APInt U;
for (size_t i = 0; i < std::size(ConsumeUnsigned); ++i) {
StringRef Str = ConsumeUnsigned[i].Str;
@@ -858,6 +859,12 @@ TEST(StringRefTest, consumeIntegerUnsigned) {
ASSERT_FALSE(U64Success);
EXPECT_EQ(U64, ConsumeUnsigned[i].Expected);
EXPECT_EQ(Str, ConsumeUnsigned[i].Leftover);
+
+ Str = ConsumeUnsigned[i].Str;
+ U64Success = Str.consumeInteger(0, U);
+ ASSERT_FALSE(U64Success);
+ EXPECT_EQ(U.getZExtValue(), ConsumeUnsigned[i].Expected);
+ EXPECT_EQ(Str, ConsumeUnsigned[i].Leftover);
}
}