All of the ParsePrechecks are already done by ToIntegral, so remove them from ParseIntegral.
Also:
- Remove redundant
{}. See #20457 (review) - Add missing failing c-string test case
- Add missing failing test cases for non-int32_t integral types
All of the ParsePrechecks are already done by ToIntegral, so remove them from ParseIntegral.
Also:
{}. See #20457 (review)
Also:
* Remove redundant {} from return statement
* Add missing failing c-string test case and "-" and "+" strings
* Add missing failing test cases for non-int32_t integral typesConcept ACK
@MarcoFalke Nice cleanup! I think we can get rid of the entire ParsePrechecks function now since the only remaining caller ParseDouble is unused (last use of ParseDouble removed in 78c312c983255e15fc274de2368a2ec13ce81cbf).
Note to reviewers: The string fuzzing harness (FUZZ=string src/test/fuzz/fuzz) can be used to try to test that ParseInt32 (and the other functions in that family) stays identical to the old behaviour (LegacyParseInt32) also after the removal of ParsePrechecks.
@practicalswift Good find. Removed as well.
cr ACK fa9d72a7947d2cff541794e21e0040c3c1d43b32
1473 | @@ -1474,6 +1474,35 @@ BOOST_AUTO_TEST_CASE(test_ParseInt32) 1474 | BOOST_CHECK(!ParseInt32("32482348723847471234", nullptr)); 1475 | } 1476 | 1477 | +template <typename T> 1478 | +static void RunToIntegralTests() 1479 | +{ 1480 | + BOOST_CHECK(!ToIntegral<T>(STRING_WITH_EMBEDDED_NULL_CHAR));
I like this test line.
Code review ACK fa9d72a7947d2cff541794e21e0040c3c1d43b32, good find on ParseDouble not being used at all, and testing for behavior of embedded NULL characters is always a good thing.