diff options
author | Nick Kledzik <kledzik@apple.com> | 2012-10-03 18:15:27 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2012-10-03 18:15:27 +0000 |
commit | 7a0f86fa7822ae02d9d4f8f992d854a4bcc2a8bd (patch) | |
tree | 3766ec2b188f1142447c4a5a68364091fdcfbcd2 /unittests/ADT | |
parent | 739dc6e6d84bee77d8af08382967ee86107eea54 (diff) | |
download | external_llvm-7a0f86fa7822ae02d9d4f8f992d854a4bcc2a8bd.zip external_llvm-7a0f86fa7822ae02d9d4f8f992d854a4bcc2a8bd.tar.gz external_llvm-7a0f86fa7822ae02d9d4f8f992d854a4bcc2a8bd.tar.bz2 |
Add getAsUnsignedInteger test case that checks that known bad values are rejected
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165136 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ADT')
-rw-r--r-- | unittests/ADT/StringRefTest.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/unittests/ADT/StringRefTest.cpp b/unittests/ADT/StringRefTest.cpp index 315eacb..59eed54 100644 --- a/unittests/ADT/StringRefTest.cpp +++ b/unittests/ADT/StringRefTest.cpp @@ -456,4 +456,23 @@ TEST(StringRefTest, getAsInteger) { } } + +static const char* BadStrings[] = { + "18446744073709551617" // value just over max + , "123456789012345678901" // value way too large + , "4t23v" // illegal decimal characters + , "0x123W56" // illegal hex characters +}; + + +TEST(StringRefTest, getAsUnsignedIntegerBadStrings) { + uint64_t U64; + for (size_t i = 0; i < array_lengthof(BadStrings); ++i) { + bool IsBadNumber = getAsUnsignedInteger(BadStrings[i], 0, U64); + ASSERT_TRUE(IsBadNumber); + } +} + + + } // end anonymous namespace |