Improve failure reporting and add more assertions
Adds BV_NOTHROW, BV_THROWS, and BV_THROWS_ANY. Improves failure reporting.
This commit is contained in:
@@ -9,9 +9,110 @@ BV_TEST(sanity, "basic sanity check")
|
||||
BV_ASSERT_NOT_EQUAL(0, 1);
|
||||
}
|
||||
|
||||
BV_TEST(ignored, "ignored test")
|
||||
BV_TEST(ignore, "test BV_IGNORE")
|
||||
{
|
||||
BV_IGNORE;
|
||||
try {
|
||||
BV_IGNORE;
|
||||
}
|
||||
catch (bitshift::validate::ignored const&) {
|
||||
BV_PASS;
|
||||
}
|
||||
catch (...) {
|
||||
// Fall-through.
|
||||
//
|
||||
}
|
||||
|
||||
BV_FAIL("expected exception not thrown");
|
||||
}
|
||||
|
||||
BV_TEST(pass, "test BV_PASS")
|
||||
{
|
||||
try {
|
||||
BV_PASS;
|
||||
}
|
||||
catch (bitshift::validate::passed const&) {
|
||||
BV_PASS;
|
||||
}
|
||||
catch (...) {
|
||||
// Fall-through.
|
||||
//
|
||||
}
|
||||
|
||||
BV_FAIL("expected exception not thrown");
|
||||
}
|
||||
|
||||
BV_TEST(fail, "test BV_FAIL")
|
||||
{
|
||||
try {
|
||||
BV_FAIL("message");
|
||||
}
|
||||
catch (bitshift::validate::failure const&) {
|
||||
BV_PASS;
|
||||
}
|
||||
catch (...) {
|
||||
// Fall-through.
|
||||
//
|
||||
}
|
||||
|
||||
BV_FAIL("expected exception not thrown");
|
||||
}
|
||||
|
||||
BV_TEST(nothrow, "test BV_ASSERT_NOTHROW")
|
||||
{
|
||||
struct except {};
|
||||
|
||||
try {
|
||||
// This assertion should fail.
|
||||
//
|
||||
BV_ASSERT_NOTHROW(throw except{});
|
||||
}
|
||||
catch (bitshift::validate::failure const&) {
|
||||
BV_PASS;
|
||||
}
|
||||
catch (...) {
|
||||
// Fall-through.
|
||||
//
|
||||
}
|
||||
|
||||
BV_FAIL("expected exception not thrown");
|
||||
}
|
||||
|
||||
BV_TEST(throws, "test BV_ASSERT_THROWS")
|
||||
{
|
||||
struct except {};
|
||||
|
||||
try {
|
||||
// This assertion should fail.
|
||||
//
|
||||
BV_ASSERT_THROWS(except, (void)0);
|
||||
}
|
||||
catch (bitshift::validate::failure const&) {
|
||||
BV_PASS;
|
||||
}
|
||||
catch (...) {
|
||||
// Fall-through.
|
||||
//
|
||||
}
|
||||
|
||||
BV_FAIL("expected exception not thrown");
|
||||
}
|
||||
|
||||
BV_TEST(throws_any, "test BV_ASSERT_THROWS_ANY")
|
||||
{
|
||||
try {
|
||||
// This assertion should fail.
|
||||
//
|
||||
BV_ASSERT_THROWS_ANY((void)0);
|
||||
}
|
||||
catch (bitshift::validate::failure const&) {
|
||||
BV_PASS;
|
||||
}
|
||||
catch (...) {
|
||||
// Fall-through.
|
||||
//
|
||||
}
|
||||
|
||||
BV_FAIL("expected exception not thrown");
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user