Add ability to convert larger numbers without fast_float, write unit tests

This commit is contained in:
ado
2023-08-08 14:11:51 +02:00
parent b9d2c2aad9
commit 672b89b213
4 changed files with 60 additions and 19 deletions

View File

@@ -63,11 +63,6 @@ TEST_CASE("extract test functions for numbers with invalid inputs") {
// random input for float
CHECK_INVALID_CONVERSION("xxx1", float);
// number too big
CHECK_INVALID_CONVERSION((std::string(40, '1') + "." +
std::string(40, '2')),
double);
// random input for int
CHECK_INVALID_CONVERSION("xxx1", int);
@@ -280,3 +275,20 @@ TEST_CASE("extract test functions for std::variant") {
}
}
}
TEST_CASE("extract test with long number string") {
{
std::string string_num =
std::string(20, '1') + "." + std::string(20, '2');
CHECK_FLOATING_CONVERSION_LONG_NUMBER(string_num, float, stof);
CHECK_FLOATING_CONVERSION_LONG_NUMBER(string_num, double, stod);
}
{
std::string string_num =
std::string(50, '1') + "." + std::string(50, '2');
CHECK_FLOATING_CONVERSION_LONG_NUMBER(string_num, double, stod);
}
}