const_container/test/common_helper/test_ret_val.h

42 lines
1.1 KiB
C++

#ifndef CONST_CONTAINER_TEST_RETURN_VAL_H_
#define CONST_CONTAINER_TEST_RETURN_VAL_H_
#include <concepts>
#include <const_list.h>
#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 test_ret_val {
struct ret_val_s : public cc::const_list_node<ret_val_s> {
ReturnCode val = FAILED;
const char *msg = "";
};
cc::const_list<ret_val_s> list;
constexpr test_ret_val() = default;
constexpr test_ret_val(const test_ret_val& other) = delete;
constexpr test_ret_val(test_ret_val&& other) = default;
constexpr test_ret_val& operator=(const test_ret_val& other) = delete;
constexpr test_ret_val& operator=(test_ret_val&& other) = default;
constexpr operator bool() const { return std::all_of(list.cbegin(), list.cend(), [](auto e){ return !static_cast<bool>(e.val); }); }
};*/
struct ret_val_s {
const char *test_name = "";
ReturnCode val = FAILED;
const char *msg = "";
};
template<std::size_t Nr>
using ret_val = std::array<ret_val_s, Nr>;
#endif //CONST_CONTAINER_TEST_RETURN_VAL_H_