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;
|
|
|
|
|
2016-01-20 16:38:54 +11:00
|
|
|
tap.expect_eq (util::format::render ("identity"), "identity"s, "identity literal");
|
|
|
|
tap.expect_eq (util::format::render ("%s", "identity"s), "identity"s, "identity string substitution");
|
|
|
|
tap.expect_eq (util::format::render ("%s", "identity" ), "identity"s, "identity char[] substitution");
|
2015-07-21 01:37:45 +10:00
|
|
|
|
2016-01-20 16:39:20 +11:00
|
|
|
tap.expect_throw<util::format::missing_error> ([] (void) {
|
|
|
|
util::format::render ("%s");
|
|
|
|
}, "missing value");
|
|
|
|
|
2016-04-27 16:12:24 +10:00
|
|
|
tap.expect_throw<util::format::invalid_specifier<int>> ([] (void) {
|
2016-02-03 12:02:56 +11:00
|
|
|
util::format::render ("%<", 42);
|
2016-01-20 16:39:20 +11:00
|
|
|
}, "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 ();
|
|
|
|
}
|