mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +00:00
AK: Trim whitespace in StringUtils::convert_to_{int,uint,uint_from_hex}()
Personally I found this unintuitive at first, but it is in line with strtol(), Python's int() or JavaScript's parseInt(), so I guess it makes sense. Fixes #4097.
This commit is contained in:
parent
0cb16ffe08
commit
d6a4c0c79e
2 changed files with 21 additions and 10 deletions
|
@ -130,6 +130,10 @@ TEST_CASE(convert_to_int)
|
|||
actual = AK::StringUtils::convert_to_int("-12345");
|
||||
EXPECT_EQ(actual.has_value(), true);
|
||||
EXPECT_EQ(actual.value(), -12345);
|
||||
|
||||
actual = AK::StringUtils::convert_to_int(" \t-12345 \n\n");
|
||||
EXPECT_EQ(actual.has_value(), true);
|
||||
EXPECT_EQ(actual.value(), -12345);
|
||||
}
|
||||
|
||||
TEST_CASE(convert_to_uint)
|
||||
|
@ -170,6 +174,10 @@ TEST_CASE(convert_to_uint)
|
|||
actual = AK::StringUtils::convert_to_uint("12345");
|
||||
EXPECT_EQ(actual.has_value(), true);
|
||||
EXPECT_EQ(actual.value(), 12345u);
|
||||
|
||||
actual = AK::StringUtils::convert_to_uint(" \t12345 \n\n");
|
||||
EXPECT_EQ(actual.has_value(), true);
|
||||
EXPECT_EQ(actual.value(), 12345u);
|
||||
}
|
||||
|
||||
TEST_CASE(ends_with)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue