Files
bitshift-validate/tests/sanity-check/driver.cxx
T

123 lines
1.9 KiB
C++
Raw Normal View History

2026-06-24 14:13:35 +02:00
#include <bitshift/validate/validate.hxx>
BV_TEST(sanity, "basic sanity check")
{
BV_ASSERT_TRUE(true);
BV_ASSERT_FALSE(false);
BV_ASSERT_NULLPTR(nullptr);
BV_ASSERT_EQUAL(1, 1);
BV_ASSERT_NOT_EQUAL(0, 1);
}
BV_TEST(ignore, "test BV_IGNORE")
2026-06-24 14:13:35 +02:00
{
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");
2026-06-24 14:13:35 +02:00
}
int
main(int argc, char* argv[])
{
return bitshift::validate::main(argc, argv);
}