tighter checking of what is a valid integer/floating point number

also use the check consistently when converting numbers
This commit is contained in:
Axel Kohlmeyer
2022-12-17 22:06:50 -05:00
parent b6c7d24b6d
commit 5a18cea6c9
2 changed files with 35 additions and 16 deletions

View File

@ -315,6 +315,26 @@ TEST(Utils, text_not_an_integer)
ASSERT_FALSE(utils::is_integer("one"));
}
TEST(Utils, minus_not_an_integer)
{
ASSERT_FALSE(utils::is_integer("1-"));
}
TEST(Utils, plus_not_an_integer)
{
ASSERT_FALSE(utils::is_integer("1+"));
}
TEST(Utils, minus_not_a_double)
{
ASSERT_FALSE(utils::is_double("1-"));
}
TEST(Utils, plus_not_a_double)
{
ASSERT_FALSE(utils::is_double("1+"));
}
TEST(Utils, text_not_a_double)
{
ASSERT_FALSE(utils::is_double("half"));
@ -365,6 +385,11 @@ TEST(Utils, signed_double_and_exponential)
ASSERT_TRUE(utils::is_double("-10E-22"));
}
TEST(Utils, signed_double_and_broken_exponential)
{
ASSERT_FALSE(utils::is_double("-10e10-2"));
}
TEST(Utils, is_double_with_d_exponential)
{
ASSERT_FALSE(utils::is_double("10d22"));