mirror of
https://github.com/fmtlib/fmt.git
synced 2026-02-08 18:56:47 +08:00
test(scan): add basic float scan coverage (#4644)
This commit is contained in:
parent
bf3babfd7c
commit
cbd4fc18c3
@ -58,6 +58,22 @@ TEST(scan_test, read_hex) {
|
|||||||
fmt::format_error, "number is too big");
|
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) {
|
TEST(scan_test, read_string) {
|
||||||
EXPECT_EQ(fmt::scan<std::string>("foo", "{}")->value(), "foo");
|
EXPECT_EQ(fmt::scan<std::string>("foo", "{}")->value(), "foo");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user