Add unit tests for dump_integer
Add some unit tests for formatting integers to keep code coverage as before.
This commit is contained in:
parent
be9b4cbd60
commit
c9dd260a4c
1 changed files with 60 additions and 0 deletions
|
@ -471,4 +471,64 @@ TEST_CASE("formatting")
|
||||||
check_double( 1.2345e+21, "1.2344999999999999e+21" ); // 1.2345e+21 1.2344999999999999e+21 1.2345e21
|
check_double( 1.2345e+21, "1.2344999999999999e+21" ); // 1.2345e+21 1.2344999999999999e+21 1.2345e21
|
||||||
check_double( 1.2345e+22, "1.2345e+22" ); // 1.2345e+22 1.2345e+22 1.2345e22
|
check_double( 1.2345e+22, "1.2345e+22" ); // 1.2345e+22 1.2345e+22 1.2345e22
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("integer")
|
||||||
|
{
|
||||||
|
auto check_integer = [](std::int64_t number, const std::string & expected)
|
||||||
|
{
|
||||||
|
nlohmann::json j = number;
|
||||||
|
CHECK(j.dump() == expected);
|
||||||
|
};
|
||||||
|
|
||||||
|
// edge cases
|
||||||
|
check_integer(INT64_MIN, "-9223372036854775808");
|
||||||
|
check_integer(INT64_MAX, "9223372036854775807");
|
||||||
|
|
||||||
|
// few random big integers
|
||||||
|
check_integer(-3456789012345678901LL, "-3456789012345678901");
|
||||||
|
check_integer(3456789012345678901LL, "3456789012345678901");
|
||||||
|
check_integer(-5678901234567890123LL, "-5678901234567890123");
|
||||||
|
check_integer(5678901234567890123LL, "5678901234567890123");
|
||||||
|
|
||||||
|
// integers with various digit counts
|
||||||
|
check_integer(-1000000000000000000LL, "-1000000000000000000");
|
||||||
|
check_integer(-100000000000000000LL, "-100000000000000000");
|
||||||
|
check_integer(-10000000000000000LL, "-10000000000000000");
|
||||||
|
check_integer(-1000000000000000LL, "-1000000000000000");
|
||||||
|
check_integer(-100000000000000LL, "-100000000000000");
|
||||||
|
check_integer(-10000000000000LL, "-10000000000000");
|
||||||
|
check_integer(-1000000000000LL, "-1000000000000");
|
||||||
|
check_integer(-100000000000LL, "-100000000000");
|
||||||
|
check_integer(-10000000000LL, "-10000000000");
|
||||||
|
check_integer(-1000000000LL, "-1000000000");
|
||||||
|
check_integer(-100000000LL, "-100000000");
|
||||||
|
check_integer(-10000000LL, "-10000000");
|
||||||
|
check_integer(-1000000LL, "-1000000");
|
||||||
|
check_integer(-100000LL, "-100000");
|
||||||
|
check_integer(-10000LL, "-10000");
|
||||||
|
check_integer(-1000LL, "-1000");
|
||||||
|
check_integer(-100LL, "-100");
|
||||||
|
check_integer(-10LL, "-10");
|
||||||
|
check_integer(-1LL, "-1");
|
||||||
|
check_integer(0, "0");
|
||||||
|
check_integer(1LL, "1");
|
||||||
|
check_integer(10LL, "10");
|
||||||
|
check_integer(100LL, "100");
|
||||||
|
check_integer(1000LL, "1000");
|
||||||
|
check_integer(10000LL, "10000");
|
||||||
|
check_integer(100000LL, "100000");
|
||||||
|
check_integer(1000000LL, "1000000");
|
||||||
|
check_integer(10000000LL, "10000000");
|
||||||
|
check_integer(100000000LL, "100000000");
|
||||||
|
check_integer(1000000000LL, "1000000000");
|
||||||
|
check_integer(10000000000LL, "10000000000");
|
||||||
|
check_integer(100000000000LL, "100000000000");
|
||||||
|
check_integer(1000000000000LL, "1000000000000");
|
||||||
|
check_integer(10000000000000LL, "10000000000000");
|
||||||
|
check_integer(100000000000000LL, "100000000000000");
|
||||||
|
check_integer(1000000000000000LL, "1000000000000000");
|
||||||
|
check_integer(10000000000000000LL, "10000000000000000");
|
||||||
|
check_integer(100000000000000000LL, "100000000000000000");
|
||||||
|
check_integer(1000000000000000000LL, "1000000000000000000");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue