diff --git a/test/common_helper/test_define_test.hpp b/test/common_helper/test.hpp similarity index 85% rename from test/common_helper/test_define_test.hpp rename to test/common_helper/test.hpp index 89b8a1b..f91c431 100644 --- a/test/common_helper/test_define_test.hpp +++ b/test/common_helper/test.hpp @@ -2,8 +2,8 @@ // Created by Patrick Maschek on 08/04/2024. // -#ifndef CONST_CONTAINER_TEST_DEFINE_TEST_HPP_ -#define CONST_CONTAINER_TEST_DEFINE_TEST_HPP_ +#ifndef CONST_CONTAINER_TEST_HPP_ +#define CONST_CONTAINER_TEST_HPP_ #include #include @@ -13,17 +13,38 @@ #include #include -#include "test_ret_val.h" - #define TEST_FAIL(msg) ret_val_s { "", ReturnCode::FAILED, msg } #define TEST_PASS() ret_val_s { "", ReturnCode::PASSED, nullptr } #define TEST_PASS_MSG(msg) ret_val_s { "", ReturnCode::PASSED, msg } #define TEST_SKIP() ret_val_s { "", ReturnCode::SKIPPED, nullptr } + +enum class EvalFlag { RUNTIME, CONSTEVAL, RUNTIME_CONSTEVAL }; +enum class ReturnCode { FAILED = -1, PASSED = 0, SKIPPED = 1, NOT_EVALUATED = 2 }; + + template struct quick_test_def; -enum class EvalFlag { RUNTIME, CONSTEVAL, RUNTIME_CONSTEVAL }; +inline std::ostream& operator<<(std::ostream& os, ReturnCode rc); + + +struct ret_val_s { + const char *test_name = ""; + ReturnCode val = ReturnCode::FAILED; + const char *msg = ""; +}; + +template +struct ret_val { + const char * name; + std::array vals; + + [[nodiscard]] constexpr inline std::size_t size() const { return vals.size(); } + + constexpr inline ret_val_s& operator[](std::size_t i) { return vals[i]; } + constexpr inline const ret_val_s& operator[](std::size_t i) const { return vals[i]; } +}; class test_definition { public: @@ -188,4 +209,19 @@ constexpr auto define_tests(const char *name) { return quick_test_def { test_suite<>{ name, std::make_tuple() } }; } -#endif //CONST_CONTAINER_TEST_DEFINE_TEST_HPP_ +inline std::ostream& operator<<(std::ostream& os, ReturnCode rc) { + switch (rc) { + case ReturnCode::FAILED: + return os << "FAILED"; + case ReturnCode::PASSED: + return os << "PASSED"; + case ReturnCode::SKIPPED: + return os << "SKIPPED"; + case ReturnCode::NOT_EVALUATED: + return os << "NOT EVALUATED"; + default: + return os; + } +} + +#endif //CONST_CONTAINER_TEST_HPP_ diff --git a/test/common_helper/test_ret_val.h b/test/common_helper/test_ret_val.h deleted file mode 100644 index e3ca2d4..0000000 --- a/test/common_helper/test_ret_val.h +++ /dev/null @@ -1,43 +0,0 @@ - -#ifndef CONST_CONTAINER_TEST_RETURN_VAL_H_ -#define CONST_CONTAINER_TEST_RETURN_VAL_H_ - -#include - -#include - -enum ReturnCode { FAILED = -1, PASSED = 0, SKIPPED = 1, NOT_EVALUATED = 2 }; - -struct ret_val_s { - const char *test_name = ""; - ReturnCode val = FAILED; - const char *msg = ""; -}; - -template -struct ret_val { - const char * name; - std::array vals; - - [[nodiscard]] constexpr inline std::size_t size() const { return vals.size(); } - - constexpr inline ret_val_s& operator[](std::size_t i) { return vals[i]; } - constexpr inline const ret_val_s& operator[](std::size_t i) const { return vals[i]; } -}; - -std::ostream& operator<<(std::ostream& os, const ReturnCode &rc) { - switch (rc) { - case FAILED: - return os << "FAILED"; - case PASSED: - return os << "PASSED"; - case SKIPPED: - return os << "SKIPPED"; - case NOT_EVALUATED: - return os << "NOT EVALUATED"; - default: - return os; - } -} - -#endif //CONST_CONTAINER_TEST_RETURN_VAL_H_ diff --git a/test/const_vector/const_vector_constructor.test.cpp b/test/const_vector/const_vector_constructor.test.cpp index 2075b69..bb51e63 100644 --- a/test/const_vector/const_vector_constructor.test.cpp +++ b/test/const_vector/const_vector_constructor.test.cpp @@ -1,7 +1,6 @@ #include -#include "test_define_test.hpp" -#include "test_ret_val.h" +#include "test.hpp" constexpr test_suite tests = define_tests("Tests") ("Test Runtime", [](int = 1) constexpr{