moved test_ret_val and test_def into one header
This commit is contained in:
parent
8a1d6385ef
commit
78d1f1cca8
|
|
@ -2,8 +2,8 @@
|
||||||
// Created by Patrick Maschek on 08/04/2024.
|
// Created by Patrick Maschek on 08/04/2024.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CONST_CONTAINER_TEST_DEFINE_TEST_HPP_
|
#ifndef CONST_CONTAINER_TEST_HPP_
|
||||||
#define CONST_CONTAINER_TEST_DEFINE_TEST_HPP_
|
#define CONST_CONTAINER_TEST_HPP_
|
||||||
|
|
||||||
#include <any>
|
#include <any>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
@ -13,17 +13,38 @@
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
#include "test_ret_val.h"
|
|
||||||
|
|
||||||
#define TEST_FAIL(msg) ret_val_s { "", ReturnCode::FAILED, msg }
|
#define TEST_FAIL(msg) ret_val_s { "", ReturnCode::FAILED, msg }
|
||||||
#define TEST_PASS() ret_val_s { "", ReturnCode::PASSED, nullptr }
|
#define TEST_PASS() ret_val_s { "", ReturnCode::PASSED, nullptr }
|
||||||
#define TEST_PASS_MSG(msg) ret_val_s { "", ReturnCode::PASSED, msg }
|
#define TEST_PASS_MSG(msg) ret_val_s { "", ReturnCode::PASSED, msg }
|
||||||
#define TEST_SKIP() ret_val_s { "", ReturnCode::SKIPPED, nullptr }
|
#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<typename Suite>
|
template<typename Suite>
|
||||||
struct quick_test_def;
|
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<std::size_t Nr>
|
||||||
|
struct ret_val {
|
||||||
|
const char * name;
|
||||||
|
std::array<ret_val_s, Nr> 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 {
|
class test_definition {
|
||||||
public:
|
public:
|
||||||
|
|
@ -188,4 +209,19 @@ constexpr auto define_tests(const char *name) {
|
||||||
return quick_test_def { test_suite<>{ name, std::make_tuple() } };
|
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_
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
|
|
||||||
#ifndef CONST_CONTAINER_TEST_RETURN_VAL_H_
|
|
||||||
#define CONST_CONTAINER_TEST_RETURN_VAL_H_
|
|
||||||
|
|
||||||
#include <concepts>
|
|
||||||
|
|
||||||
#include <const_list.h>
|
|
||||||
|
|
||||||
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<std::size_t Nr>
|
|
||||||
struct ret_val {
|
|
||||||
const char * name;
|
|
||||||
std::array<ret_val_s, Nr> 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_
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#include <const_vector.hpp>
|
#include <const_vector.hpp>
|
||||||
|
|
||||||
#include "test_define_test.hpp"
|
#include "test.hpp"
|
||||||
#include "test_ret_val.h"
|
|
||||||
|
|
||||||
constexpr test_suite tests = define_tests("Tests")
|
constexpr test_suite tests = define_tests("Tests")
|
||||||
("Test Runtime", [](int = 1) constexpr{
|
("Test Runtime", [](int = 1) constexpr{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue