diff options
| author | Markus Mittendrein <maxmitti@maxmitti.tk> | 2022-01-07 18:40:42 +0100 |
|---|---|---|
| committer | Markus Mittendrein <maxmitti@maxmitti.tk> | 2022-01-07 22:50:08 +0100 |
| commit | cb71e001e5088e9006c00634ce833f5659af855c (patch) | |
| tree | 1bb004bdbbae91442437ca0e93104f17494cc2af /main.cpp | |
| parent | 4f2eb7c1dfe467aa2d7a6652a111edc74aa7b0a1 (diff) | |
| download | cxxformat-cb71e001e5088e9006c00634ce833f5659af855c.tar.gz cxxformat-cb71e001e5088e9006c00634ce833f5659af855c.zip | |
Add runtime implementation and refactor format_spec checks in formatters
Diffstat (limited to 'main.cpp')
| -rw-r--r-- | main.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -18,6 +18,19 @@ void numberTests() int main(int argc, char* argv[]) { using namespace format; + using format::format; + + if (argc == 2) + { + std::string_view fmt{argv[1]}; + format_nothrow_to(fmt, stdout, "Knirp", 's', argv[0], 42u, 1.337); + putchar('\n'); + return 0; + } + + format_to("Hallo %%du %1$s %s%c %s %u = %4$#x = %4$#X = %4$#o %f!\n", std::cout, "Knirp", 's', argv[0], 42u, 1.337); + assert(format("Hallo %%du %1$s %s%c %s %u = %4$#x = %4$#X = %4$#o %f!\n", "Knirp", 's', argv[0], 42u, 1.337) == "Hallo %%du %1$s %s%c %s %u = %4$#x = %4$#X = %4$#o %f!\n"_format("Knirp", 's', argv[0], 42u, 1.337)); + "-%20g-\n"_format_to(stdout, 0x1.8p0); "-%20.0a-\n"_format_to(stdout, 0.0); "-%#+20.0a-\n"_format_to(stdout, 1.0); |
