aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/StringRefTest.cpp
diff options
context:
space:
mode:
authorIlia Kuklin <ikuklin@accesssoftek.com>2025-08-07 22:48:17 +0500
committerGitHub <noreply@github.com>2025-08-07 22:48:17 +0500
commit2ff44d7d658beca1724f04211e194bf4beb2a1a0 (patch)
treeb2a805f7c681f5f48ebfe79c2008d5cd711d85b0 /llvm/unittests/ADT/StringRefTest.cpp
parent06f06deb774ada5aa37db89fa7b4a88b13163e0d (diff)
downloadllvm-2ff44d7d658beca1724f04211e194bf4beb2a1a0.zip
llvm-2ff44d7d658beca1724f04211e194bf4beb2a1a0.tar.gz
llvm-2ff44d7d658beca1724f04211e194bf4beb2a1a0.tar.bz2
[ADT] Make `getAutoSenseRadix` in `StringRef` global (#152503)
Needed in #152308
Diffstat (limited to 'llvm/unittests/ADT/StringRefTest.cpp')
-rw-r--r--llvm/unittests/ADT/StringRefTest.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index ec9cdc1..d5f8dc4 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -619,6 +619,19 @@ TEST(StringRefTest, Hashing) {
hash_value(StringRef("hello world").slice(1, -1)));
}
+TEST(StringRefTest, getAutoSenseRadix) {
+ struct RadixPair {
+ const char *Str;
+ unsigned Expected;
+ } RadixNumbers[] = {{"123", 10}, {"1", 10}, {"0b1", 2}, {"01", 8}, {"0o1", 8},
+ {"0x1", 16}, {"0", 10}, {"00", 8}, {"", 10}};
+ for (size_t i = 0; i < std::size(RadixNumbers); ++i) {
+ StringRef number = RadixNumbers[i].Str;
+ unsigned radix = getAutoSenseRadix(number);
+ EXPECT_EQ(radix, RadixNumbers[i].Expected);
+ }
+}
+
struct UnsignedPair {
const char *Str;
uint64_t Expected;