32 lines
790 B
C++
32 lines
790 B
C++
|
#include <cruft/util/format/quoted.hpp>
|
||
|
|
||
|
#include <cruft/util/tap.hpp>
|
||
|
|
||
|
|
||
|
int main ()
|
||
|
{
|
||
|
static constexpr struct {
|
||
|
std::string_view format;
|
||
|
std::string_view inner;
|
||
|
std::string_view result;
|
||
|
std::string_view message;
|
||
|
} TESTS[] = {
|
||
|
{ "{}", "Foo", R"("Foo")", "Simple word" },
|
||
|
{ "{}", "F\"oo", R"("F\"oo")", "Embedded delim" },
|
||
|
{ "{}", "F\\oo", R"("F\\oo")", "Embedded escape" },
|
||
|
};
|
||
|
|
||
|
cruft::TAP::logger tap;
|
||
|
|
||
|
for (auto const &t: TESTS) {
|
||
|
auto const result = fmt::vformat (
|
||
|
t.format,
|
||
|
fmt::make_format_args (
|
||
|
cruft::format::quoted (t.inner)
|
||
|
)
|
||
|
);
|
||
|
tap.expect_eq (result, t.result, "quoted format: {}", t.message);
|
||
|
}
|
||
|
|
||
|
return tap.status ();
|
||
|
}
|