diff --git a/tap.hpp b/tap.hpp index cec93d36..7cb3fe94 100644 --- a/tap.hpp +++ b/tap.hpp @@ -44,34 +44,34 @@ namespace util { namespace TAP { //--------------------------------------------------------------------- template - void expect_eq (const T&, const U&, const std::string &fmt = "equality", Args&...); + void expect_eq (const T&, const U&, const std::string &fmt, Args&...); template - void expect_neq (const T&, const U&, const std::string &msg = "inequality", Args&...); + void expect_neq (const T&, const U&, const std::string &fmt, Args&...); //--------------------------------------------------------------------- template - void expect_gt (const T&, const U&, const std::string &msg = "gt", Args&...); + void expect_gt (const T&, const U&, const std::string &fmt, Args&...); template - void expect_ge (const T&, const U&, const std::string &msg = "ge", Args&...); + void expect_ge (const T&, const U&, const std::string &fmt, Args&...); template - void expect_lt (const T&, const U&, const std::string &msg = "lt", Args&...); + void expect_lt (const T&, const U&, const std::string &fmt, Args&...); template - void expect_le (const T&, const U&, const std::string &msg = "le", Args&...); + void expect_le (const T&, const U&, const std::string &fmt, Args&...); //--------------------------------------------------------------------- template - void expect_nan (const T&, const std::string &msg = "nan", Args&...); + void expect_nan (const T&, const std::string &fmt, Args&...); //--------------------------------------------------------------------- template - void expect_nothrow (T&&, const std::string &msg = "nothrow", Args&...); + void expect_nothrow (T&&, const std::string &fmt, Args&...); template - void expect_throw (T&&, const std::string &msg = "throw", Args&...); + void expect_throw (T&&, const std::string &fmt, Args&...); //--------------------------------------------------------------------- void skip (const std::string &msg); diff --git a/test/bitwise.cpp b/test/bitwise.cpp index db9fa273..c54d899c 100644 --- a/test/bitwise.cpp +++ b/test/bitwise.cpp @@ -6,33 +6,33 @@ static void test_rotate (util::TAP::logger &tap) { - tap.expect_eq (rotatel (uint8_t (0x0F), 0), 0x0F); - tap.expect_eq (rotatel (uint8_t (0x0F), 4), 0xF0); - tap.expect_eq (rotatel (uint8_t (0xF0), 4), 0x0F); - tap.expect_eq (rotatel (uint8_t (0x0F), 8), 0x0F); + tap.expect_eq (rotatel (uint8_t (0x0F), 0), 0x0F, "rotate-left u8"); + tap.expect_eq (rotatel (uint8_t (0x0F), 4), 0xF0, "rotate-left u8"); + tap.expect_eq (rotatel (uint8_t (0xF0), 4), 0x0F, "rotate-left u8"); + tap.expect_eq (rotatel (uint8_t (0x0F), 8), 0x0F, "rotate-left u8"); - tap.expect_eq (rotater (uint8_t (0x0F), 0), 0x0F); - tap.expect_eq (rotater (uint8_t (0x0F), 4), 0xF0); - tap.expect_eq (rotater (uint8_t (0xF0), 4), 0x0F); - tap.expect_eq (rotater (uint8_t (0x0F), 8), 0x0F); + tap.expect_eq (rotater (uint8_t (0x0F), 0), 0x0F, "rotate-right u8"); + tap.expect_eq (rotater (uint8_t (0x0F), 4), 0xF0, "rotate-right u8"); + tap.expect_eq (rotater (uint8_t (0xF0), 4), 0x0F, "rotate-right u8"); + tap.expect_eq (rotater (uint8_t (0x0F), 8), 0x0F, "rotate-right u8"); - tap.expect_eq (rotatel (uint16_t (0xABCD), 0), 0xABCD); - tap.expect_eq (rotatel (uint16_t (0xABCD), 4), 0xBCDA); - tap.expect_eq (rotatel (uint16_t (0xABCD), 8), 0xCDAB); - tap.expect_eq (rotatel (uint16_t (0xABCD), 12), 0xDABC); - tap.expect_eq (rotatel (uint16_t (0xABCD), 16), 0xABCD); + tap.expect_eq (rotatel (uint16_t (0xABCD), 0), 0xABCD, "rotate-left u16"); + tap.expect_eq (rotatel (uint16_t (0xABCD), 4), 0xBCDA, "rotate-left u16"); + tap.expect_eq (rotatel (uint16_t (0xABCD), 8), 0xCDAB, "rotate-left u16"); + tap.expect_eq (rotatel (uint16_t (0xABCD), 12), 0xDABC, "rotate-left u16"); + tap.expect_eq (rotatel (uint16_t (0xABCD), 16), 0xABCD, "rotate-left u16"); - tap.expect_eq (rotater (uint16_t (0xABCD), 0), 0xABCD); - tap.expect_eq (rotater (uint16_t (0xABCD), 4), 0xDABC); - tap.expect_eq (rotater (uint16_t (0xABCD), 8), 0xCDAB); - tap.expect_eq (rotater (uint16_t (0xABCD), 12), 0xBCDA); - tap.expect_eq (rotater (uint16_t (0xABCD), 16), 0xABCD); + tap.expect_eq (rotater (uint16_t (0xABCD), 0), 0xABCD, "rotate-right u16"); + tap.expect_eq (rotater (uint16_t (0xABCD), 4), 0xDABC, "rotate-right u16"); + tap.expect_eq (rotater (uint16_t (0xABCD), 8), 0xCDAB, "rotate-right u16"); + tap.expect_eq (rotater (uint16_t (0xABCD), 12), 0xBCDA, "rotate-right u16"); + tap.expect_eq (rotater (uint16_t (0xABCD), 16), 0xABCD, "rotate-right u16"); - tap.expect_eq (rotatel (uint32_t (0x12345670), 12), 0x45670123); - tap.expect_eq (rotater (uint32_t (0x12345670), 12), 0x67012345); + tap.expect_eq (rotatel (uint32_t (0x12345670), 12), 0x45670123, "rotate-left u32"); + tap.expect_eq (rotater (uint32_t (0x12345670), 12), 0x67012345, "rotate-right u32"); - tap.expect_eq (rotatel (uint64_t (0x1234567890ABCDEF), 12), 0x4567890ABCDEF123); - tap.expect_eq (rotater (uint64_t (0x1234567890ABCDEF), 12), 0xDEF1234567890ABC); + tap.expect_eq (rotatel (uint64_t (0x1234567890ABCDEF), 12), 0x4567890ABCDEF123, "rotate-left u64"); + tap.expect_eq (rotater (uint64_t (0x1234567890ABCDEF), 12), 0xDEF1234567890ABC, "rotate-right u64"); } diff --git a/test/cmdopt.cpp b/test/cmdopt.cpp index 59c36cc0..f4544da9 100644 --- a/test/cmdopt.cpp +++ b/test/cmdopt.cpp @@ -17,12 +17,12 @@ test_null (util::TAP::logger &tap) static const char *argv1[] = { "./foo", "-n", "foo" }; tap.expect_nothrow ([&] () { p.scan (elems (argv1), argv1); - }); + }, "nothrow null short form"); static const char *argv2[] = { "./foo", "--null", "foo" }; tap.expect_nothrow ([&] () { p.scan (elems (argv2), argv2); - }); + }, "nothrow null long form"); } @@ -81,13 +81,13 @@ test_bool (util::TAP::logger &tap) for (auto i: positive) { argv[2] = i; p.scan (argv.size (), argv.data ()); - tap.expect_eq (value, true, i); + tap.expect_eq (value, true, i, "read bool, %s", i); } for (auto i: negative) { argv[2] = i; p.scan (argv.size (), argv.data ()); - tap.expect_eq (value, false, i); + tap.expect_eq (value, false, i, "read bool, %s", i); } // Check that invalid forms of boolean all throw exceptions @@ -97,7 +97,7 @@ test_bool (util::TAP::logger &tap) argv[2] = i; tap.expect_throw ([&] () { p.scan (argv.size (), argv.data ()); - }); + }, "invalid bool, %s", i); } } @@ -137,7 +137,7 @@ test_numeric (util::TAP::logger &tap) // check short form reading value = 2; p.scan (elems (argv_short), argv_short); - tap.expect_eq (value, values[i]); + tap.expect_eq (value, values[i], "equality, short form"); // construct long form arguments out_long << "--type=" << values[i]; @@ -147,7 +147,7 @@ test_numeric (util::TAP::logger &tap) // check long form reading value = 2; p.scan (elems (argv_long), argv_long); - tap.expect_eq (value, values[i]); + tap.expect_eq (value, values[i], "equality, long form"); } } @@ -181,7 +181,7 @@ test_bytes (util::TAP::logger &tap) argv[2] = i.str; p.scan (elems (argv), argv); - tap.expect_eq (i.val, size, "bytes"); + tap.expect_eq (i.val, size, "bytes, %s", i.str); }; } @@ -205,11 +205,11 @@ test_required (util::TAP::logger &tap) tap.expect_nothrow ([&] () { p.scan (elems (argv), argv); - }); + }, "required option, success"); tap.expect_throw ([&] () { p.scan (1, argv); - }); + }, "required option, failure"); } diff --git a/test/format.cpp b/test/format.cpp index 0e12d856..bdaa5980 100644 --- a/test/format.cpp +++ b/test/format.cpp @@ -12,9 +12,9 @@ main (void) tap.expect_eq (util::format::render ("identity"), "identity"s, "identity literal"); tap.expect_eq (util::format::render ("%s", "identity"s), "identity"s, "identity substitution"); - tap.expect_throw ([] (void) { util::format::render ("%s"); }); - tap.expect_throw ([] (void) { util::format::render ("%!", 42); }); - tap.expect_throw ([] (void) { util::format::render ("%", 42); }); + tap.expect_throw ([] (void) { util::format::render ("%s"); }, "missing value"); + tap.expect_throw ([] (void) { util::format::render ("%!", 42); }, "invalid specifier"); + tap.expect_throw ([] (void) { util::format::render ("%", 42); }, "truncated specifier"); return tap.status (); }