Skip to content

Commit a9c8fac

Browse files
committed
test(scan): document current exponent parsing behavior
1 parent cbd4fc1 commit a9c8fac

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/scan-test.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,36 @@ TEST(scan_test, read_string_view) {
8282
EXPECT_EQ(fmt::scan<fmt::string_view>("foo", "{}")->value(), "foo");
8383
}
8484

85+
TEST(scan_test, read_double_exponent_current_behavior) {
86+
// Exponent (e/E) and leading '+' parsing are not supported yet.
87+
{
88+
fmt::string_view input = "1e3";
89+
double value = 0.0;
90+
auto it = fmt::scan_to(input, "{}", value);
91+
EXPECT_DOUBLE_EQ(value, 1.0);
92+
ASSERT_NE(it, input.end());
93+
EXPECT_EQ(*it, 'e');
94+
}
95+
96+
{
97+
fmt::string_view input = "-2.5e-2";
98+
double value = 0.0;
99+
auto it = fmt::scan_to(input, "{}", value);
100+
EXPECT_DOUBLE_EQ(value, -2.5);
101+
ASSERT_NE(it, input.end());
102+
EXPECT_EQ(*it, 'e');
103+
}
104+
105+
{
106+
fmt::string_view input = "+1E6";
107+
double value = 0.0;
108+
auto it = fmt::scan_to(input, "{}", value);
109+
EXPECT_DOUBLE_EQ(value, 0.0);
110+
ASSERT_NE(it, input.end());
111+
EXPECT_EQ(*it, '+');
112+
}
113+
}
114+
85115
TEST(scan_test, separator) {
86116
int n1 = 0, n2 = 0;
87117
fmt::scan_to("10 20", "{} {}", n1, n2);

0 commit comments

Comments
 (0)