Added passed and failed tracking for tests.

This commit is contained in:
2024-06-17 21:50:24 -04:00
parent 1ecf4f5627
commit 9af61b7c34
2 changed files with 12 additions and 0 deletions

View File

@@ -21,7 +21,10 @@ namespace jtest {
int line;
};
// Globals for test tracking
std::vector<testdef> testlist;
int passedtests;
int failedtests;
void definetest(const std::string& testname, const std::function<void()>& callback, const std::string& file, int line)
{
@@ -44,6 +47,7 @@ namespace jtest {
{.colorCode = jlog::ansi_escape_codes::FG_RED, .content = testname},
{.content = "Failed:", .delimiter = ""}
});
failedtests++;
return false;
}
@@ -52,6 +56,7 @@ namespace jtest {
{.colorCode = jlog::ansi_escape_codes::FG_GREEN, .content = testname},
{.content = "Passed:", .delimiter = ""}
});
passedtests++;
return true;
}
@@ -63,6 +68,8 @@ namespace jtest {
{
test(td.testname, td.callback, td.file, td.line);
USINFO("Tests ran: " + std::to_string(i) + "/" + std::to_string(testlist.size()));
USINFO("Tests passed: " + std::to_string(passedtests));
USINFO("Tests failed: " + std::to_string(failedtests));
i++;
}

View File

@@ -26,6 +26,11 @@ int main(int argc, char** argv)
jtest::check(2+2 == 5);
});
TEST("Test3", []
{
jtest::check(6+9 == 69);
});
/*
TEST("LMAO");
TEST("KEKERINO")