mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-25 19:59:57 +01:00
Make scan variadic
This commit is contained in:
@@ -111,11 +111,16 @@ TEST(scan_test, invalid_format) {
|
||||
}
|
||||
|
||||
TEST(scan_test, example) {
|
||||
std::string key;
|
||||
int value = 0;
|
||||
fmt::scan_to("answer = 42", "{} = {}", key, value);
|
||||
EXPECT_EQ(key, "answer");
|
||||
EXPECT_EQ(value, 42);
|
||||
// Example from https://wg21.link/p1729r3.
|
||||
if (auto result = fmt::scan<std::string, int>("answer = 42", "{} = {}")) {
|
||||
#ifdef __cpp_structured_bindings
|
||||
const auto& [key, value] = result->values();
|
||||
EXPECT_EQ(key, "answer");
|
||||
EXPECT_EQ(value, 42);
|
||||
#endif
|
||||
} else {
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
TEST(scan_test, end_of_input) { fmt::scan<int>("", "{}"); }
|
||||
|
||||
Reference in New Issue
Block a user