mirror of
https://github.com/fmtlib/fmt.git
synced 2026-02-05 17:30:06 +08:00
test(scan): add basic float scan coverage
This commit is contained in:
parent
7ad8004d57
commit
7e384cc40e
@ -58,6 +58,22 @@ TEST(scan_test, read_hex) {
|
||||
fmt::format_error, "number is too big");
|
||||
}
|
||||
|
||||
TEST(scan_test, read_floats) {
|
||||
auto float_result = fmt::scan<float>("3.14", "{}");
|
||||
EXPECT_TRUE(float_result);
|
||||
EXPECT_FLOAT_EQ(float_result->value(), 3.14f);
|
||||
|
||||
auto double_result = fmt::scan<double>("3.14", "{}");
|
||||
EXPECT_TRUE(double_result);
|
||||
EXPECT_DOUBLE_EQ(double_result->value(), 3.14);
|
||||
}
|
||||
|
||||
TEST(scan_test, read_double_whitespace) {
|
||||
auto result = fmt::scan<double>(" 2.5 ", "{}");
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_DOUBLE_EQ(result->value(), 2.5);
|
||||
}
|
||||
|
||||
TEST(scan_test, read_string) {
|
||||
EXPECT_EQ(fmt::scan<std::string>("foo", "{}")->value(), "foo");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user