const_container/test/common_helper/test_ret_val.h

40 lines
866 B
C
Raw Normal View History

2024-03-25 16:39:19 +01:00
#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 };
struct ret_val_s {
const char *test_name = "";
ReturnCode val = FAILED;
const char *msg = "";
};
template<std::size_t Nr>
2024-04-08 10:27:10 +02:00
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]; }
};
2024-03-25 16:39:19 +01:00
2024-04-22 11:51:35 +02:00
std::ostream& operator<<(std::ostream& os, const ReturnCode &rc) {
switch (rc) {
case FAILED:
return os << "FAILED";
case PASSED:
return os << "PASSED";
default:
return os;
}
}
2024-03-25 16:39:19 +01:00
#endif //CONST_CONTAINER_TEST_RETURN_VAL_H_