libcruft-util/test/format.cpp

21 lines
711 B
C++
Raw Normal View History

2015-07-21 01:37:45 +10:00
#include "format.hpp"
#include "tap.hpp"
int
main (void)
{
using namespace std::string_literals;
util::TAP::logger tap;
tap.expect_eq (util::format::render ("identity"), "identity"s, "identity literal");
tap.expect_eq (util::format::render ("%s", "identity"s), "identity"s, "identity substitution");
2015-07-21 03:17:20 +10:00
tap.expect_throw<util::format::missing_error> ([] (void) { util::format::render ("%s"); }, "missing value");
tap.expect_throw<util::format::format_error> ([] (void) { util::format::render ("%!", 42); }, "invalid specifier");
tap.expect_throw<util::format::format_error> ([] (void) { util::format::render ("%", 42); }, "truncated specifier");
2015-07-21 01:37:45 +10:00
return tap.status ();
}