Basically got exception handling down. Still working on assertion handling.

This commit is contained in:
2024-06-27 12:13:27 -04:00
parent 8c9bb12834
commit b57cc68b6f
3 changed files with 17 additions and 4 deletions

View File

@@ -6,6 +6,8 @@
#include <vector>
#include <jlog/jlog.hpp>
//#define NDEBUG for disabling assert, but tests still end up passing.
// TODO: Move implementation to jtest::detail
// have this file primarily expose the macros intended for users

View File

@@ -10,6 +10,7 @@
// TODO: Provide benchmarking on test running-time
#include <jtest/jtest.hpp>
#include <cassert>
void TestA() { jtest::check("Bruh" == "Bruh"); }
void TestB() { jtest::check(6*6 == 36); }
@@ -33,12 +34,21 @@ int main(int argc, char** argv)
//jtest::check(2+2 == 4);
});
/*
TEST("Test4", []
{
assert(false);
//assert(69 == 9);//, "FUCKING COCK"); stil figuring out
});
TEST("Test5", []
{
throw std::runtime_error("HOLY SHIT");
});
TEST("Test6", []
{
throw std::exception();
});
*/
TEST("TestGroup::A", TestA);
TEST("TestGroup::B", TestB);

View File

@@ -89,6 +89,8 @@ namespace jtest {
try { callback(); }
catch(const std::exception& e)
{ passed = false; }
catch(...) // <- Basically covers all exception cases. GTest does something similar
{ passed = false; }
rantests++;
@@ -106,7 +108,6 @@ namespace jtest {
for (testdef& td : testlist)
{
td.passed = test(td.testname, td.callback, td.file, td.line);
}
jlog::log(log_test_tracking_format());