A (very) tiny C++ unit-testing header-only framework.
Just include the include/ntest/ntest.hpp
to your source file and you are good to go.
// A passing test
ntest::assert_true([]()
{
return 42 == 42;
});
// A failing test
ntest::assert_true([]()
{
return 42 != 42;
});
// A shorthand macro
ASSERT_TRUE
(
return true;
)
// A passing test
ntest::assert_false([]()
{
return 42 != 42;
});
// A failing test
ntest::assert_true([]()
{
return 42 == 42;
});
// A shorthand macro
ASSERT_FALSE
(
return false;
)
// A passing test
ntest::assert_throw<int>([]()
{
throw 42;
});
// A failing test
ntest::assert_throw<int>([]()
{
return "42";
});
// A shorthand macro
ASSERT_THROW
(
int,
{
throw 42;
}
)
// A passing test
ntest::assert_nothrow([]()
{
// No exceptions are thrown here
});
// A failing test
ntest::assert_nothrow([]()
{
throw 42;
});
// A shorthand macro
ASSERT_NOTHROW
(
{
// No exceptions are thrown here
}
)
#include <ntest/ntest.hpp>
int main ( void )
{
/*
* Some assertions
*/
return ntest::run() ? 0 : 1;
}