diff --git a/test/common_helper/test_define_test.hpp b/test/common_helper/test_define_test.hpp index 9c3ecf5..38efb51 100644 --- a/test/common_helper/test_define_test.hpp +++ b/test/common_helper/test_define_test.hpp @@ -13,7 +13,9 @@ #include #include "test_ret_val.h" -#include "CompileOptional.h" + +#define TEST_FAIL(msg) ret_val_s { "", ReturnCode::FAILED, msg } +#define TEST_PASS(msg) ret_val_s { "", ReturnCode::PASSED, msg } template struct quick_test_def; @@ -45,7 +47,11 @@ class test_definition_impl : public test_definition { } } - [[nodiscard]] constexpr ret_val_s evaluate() const override { return std::apply(_func, _args); } + [[nodiscard]] constexpr ret_val_s evaluate() const override { + ret_val_s r = std::apply(_func, _args); + r.test_name = _name; + return r; + } [[nodiscard]] const char *name() const override { return _name; } [[nodiscard]] EvalFlag evalFlag() const override { return _evalFlag; } @@ -71,6 +77,7 @@ class test_suite { int run() const { auto test_arr = expand_test_tuple(_tests, std::make_index_sequence()); + int num_failed = 0; std::cout << "--------------\n"; @@ -91,16 +98,24 @@ class test_suite { std::cout << "Result of Runtime Evaluation of Test \"" << ret.test_name << "\": " << ret.val << "\n" << "\t" << ret.msg << std::endl; + + if (ret.val != ReturnCode::PASSED) { + --num_failed; + } } if (test.evalFlag() == EvalFlag::CONSTEVAL || test.evalFlag() == EvalFlag::RUNTIME_CONSTEVAL) { const ret_val_s& ret = test.c_res(); std::cout << "Result of Consteval Evaluation of Test \"" << ret.test_name << "\": " << ret.val << "\n" << "\t" << ret.msg << std::endl; + + if (ret.val != ReturnCode::PASSED) { + --num_failed; + } } } - return 0; + return num_failed; } private: diff --git a/test/common_helper/test_ret_val.h b/test/common_helper/test_ret_val.h index b315bf6..61e1544 100644 --- a/test/common_helper/test_ret_val.h +++ b/test/common_helper/test_ret_val.h @@ -6,9 +6,6 @@ #include -#define TEST_FAIL(name, msg) ret_val_s { name, ReturnCode::FAILED, msg } -#define TEST_PASS(name, msg) ret_val_s { name, ReturnCode::PASSED, msg } - enum ReturnCode { FAILED = -1, PASSED = 0 }; struct ret_val_s { diff --git a/test/const_vector/const_vector_constructor.test.cpp b/test/const_vector/const_vector_constructor.test.cpp index f10a8bd..65c85ad 100644 --- a/test/const_vector/const_vector_constructor.test.cpp +++ b/test/const_vector/const_vector_constructor.test.cpp @@ -7,34 +7,31 @@ constexpr test_suite tests = define_tests("Tests") ("Test Runtime", [](int = 1) constexpr{ - return TEST_PASS("Test Runtime", "PASS"); + return TEST_PASS("PASS"); }, EvalFlag::RUNTIME) ("Test Consteval 1", [](char = 2) constexpr { + return TEST_FAIL("ups"); if (std::is_constant_evaluated()) { - return TEST_PASS("Test Consteval", "PASS"); + return TEST_PASS("PASS"); } else { - return TEST_FAIL("Test Consteval", "FAIL"); + return TEST_FAIL("FAIL"); } }, EvalFlag::CONSTEVAL) ("Test Consteval", [](char = 2) constexpr { - //std::cout << ""; if (std::is_constant_evaluated()) { - return TEST_PASS("Test Consteval", "PASS"); + return TEST_PASS( "PASS"); } else { - return TEST_FAIL("Test Consteval", "FAIL"); + return TEST_FAIL("FAIL"); } }, EvalFlag::CONSTEVAL) ("Test Runtime Consteval", [](short = 3) constexpr{ if (std::is_constant_evaluated()) { - return TEST_PASS("Test Consteval Runtime", "PASS Consteval"); + return TEST_PASS("PASS Consteval"); } else { - return TEST_PASS("Test Consteval", "PASS Runtime"); + return TEST_PASS("PASS Runtime"); } }, EvalFlag::RUNTIME_CONSTEVAL); int main() { - - tests.run(); - - return 0; + return tests.run(); } \ No newline at end of file