150 lines
7.9 KiB
C++
150 lines
7.9 KiB
C++
#ifndef UDIFF_TEST_ARGS_H_
|
|
#define UDIFF_TEST_ARGS_H_
|
|
|
|
#include <array>
|
|
#include <initializer_list>
|
|
|
|
#include "test/common_helper/test_util.h"
|
|
|
|
struct test_defs {
|
|
|
|
#define GEN_TEST_STRUCT_ARR(nr, i) TestStruct(C_VI_TEST_ARR##nr[i], C_VC_TEST_ARR##nr[i], C_VS_TEST_ARR##nr[i])
|
|
|
|
|
|
#define TEST_VEC1_CAPACITY 5
|
|
#define TEST_VEC2_CAPACITY 10
|
|
|
|
#define TEST_VEC1_SIZE 3
|
|
#define TEST_VEC2_SIZE 7
|
|
|
|
#define VI_TEST_VAL 5
|
|
#define VC_TEST_VAL 'T'
|
|
#define VS_TEST_VAL "Test string"
|
|
#define VO_TEST_VAL TestStruct(VI_TEST_VAL, VC_TEST_VAL, VS_TEST_VAL)
|
|
|
|
#define VI_TEST_ARR1 { 1, 2, 3, 4 }
|
|
#define VI_TEST_ARR2 { 5, 6, 7, 8, 9, 10, 11, 12 }
|
|
|
|
#define VC_TEST_ARR1 { 'a', 'B', 'c', 'D' }
|
|
#define VC_TEST_ARR2 { 'e', 'F', 'g', 'H', 'i', 'J', '\n', '\0' }
|
|
|
|
#define VS_TEST_ARR1 { "Lorem", "ipsum", "dolor", "sit" }
|
|
#define VS_TEST_ARR2 { "amet", "consetetur", "sadipscing", "elitr", "sed", "diam", "nonumy", "eirmod", "tempor", "\0" }
|
|
|
|
#define VO_TEST_ARR1 { GEN_TEST_STRUCT_ARR(1, 0), \
|
|
GEN_TEST_STRUCT_ARR(1, 1), \
|
|
GEN_TEST_STRUCT_ARR(1, 2), \
|
|
GEN_TEST_STRUCT_ARR(1, 3) }
|
|
#define VO_TEST_ARR2 { GEN_TEST_STRUCT_ARR(2, 0), \
|
|
GEN_TEST_STRUCT_ARR(2, 1), \
|
|
GEN_TEST_STRUCT_ARR(2, 2), \
|
|
GEN_TEST_STRUCT_ARR(2, 3), \
|
|
GEN_TEST_STRUCT_ARR(2, 4), \
|
|
GEN_TEST_STRUCT_ARR(2, 5), \
|
|
GEN_TEST_STRUCT_ARR(2, 6), \
|
|
GEN_TEST_STRUCT_ARR(2, 7) }
|
|
|
|
static constexpr std::initializer_list<int> VI_I_LIST1 = VI_TEST_ARR1;
|
|
static constexpr std::initializer_list<int> VI_I_LIST2 = VI_TEST_ARR2;
|
|
static constexpr const int C_VI_TEST_ARR1[] = VI_TEST_ARR1;
|
|
static constexpr const int C_VI_TEST_ARR2[] = VI_TEST_ARR2;
|
|
static constexpr const std::array STD_VI_TEST_ARR1 = VI_TEST_ARR1;
|
|
static constexpr const std::array STD_VI_TEST_ARR2 = VI_TEST_ARR2;
|
|
static constexpr const std::size_t VI_TEST_ARR1_LEN = C_ARR_LEN(C_VI_TEST_ARR1);
|
|
static constexpr const std::size_t VI_TEST_ARR2_LEN = C_ARR_LEN(C_VI_TEST_ARR2);
|
|
static constexpr std::initializer_list<char> VC_I_LIST1 = VC_TEST_ARR1;
|
|
static constexpr std::initializer_list<char> VC_I_LIST2 = VC_TEST_ARR2;
|
|
static constexpr const char C_VC_TEST_ARR1[] = VC_TEST_ARR1;
|
|
static constexpr const char C_VC_TEST_ARR2[] = VC_TEST_ARR2;
|
|
static constexpr const std::array STD_VC_TEST_ARR1 = VC_TEST_ARR1;
|
|
static constexpr const std::array STD_VC_TEST_ARR2 = VC_TEST_ARR2;
|
|
static constexpr const std::size_t VC_TEST_ARR1_LEN = C_ARR_LEN(C_VC_TEST_ARR1);
|
|
static constexpr const std::size_t VC_TEST_ARR2_LEN = C_ARR_LEN(C_VC_TEST_ARR2);
|
|
static constexpr std::initializer_list<const char *> VS_I_LIST1 = VS_TEST_ARR1;
|
|
static constexpr std::initializer_list<const char *> VS_I_LIST2 = VS_TEST_ARR2;
|
|
static constexpr const char * C_VS_TEST_ARR1[] = VS_TEST_ARR1;
|
|
static constexpr const char * C_VS_TEST_ARR2[] = VS_TEST_ARR2;
|
|
static constexpr const std::array STD_VS_TEST_ARR1 = VS_TEST_ARR1;
|
|
static constexpr const std::array STD_VS_TEST_ARR2 = VS_TEST_ARR2;
|
|
static constexpr const std::size_t VS_TEST_ARR1_LEN = C_ARR_LEN(C_VS_TEST_ARR1);
|
|
static constexpr const std::size_t VS_TEST_ARR2_LEN = C_ARR_LEN(C_VS_TEST_ARR2);
|
|
static constexpr TestStruct C_VO_TEST_ARR1[] = VO_TEST_ARR1;
|
|
static constexpr TestStruct C_VO_TEST_ARR2[] = VO_TEST_ARR2;
|
|
static constexpr const std::array STD_VO_TEST_ARR1 = VO_TEST_ARR1;
|
|
static constexpr const std::array STD_VO_TEST_ARR2 = VO_TEST_ARR2;
|
|
static constexpr const std::size_t VO_TEST_ARR1_LEN = C_ARR_LEN(C_VO_TEST_ARR1);
|
|
static constexpr const std::size_t VO_TEST_ARR2_LEN = C_ARR_LEN(C_VO_TEST_ARR2);
|
|
static constexpr std::initializer_list<TestStruct> VO_I_LIST1 = VO_TEST_ARR1;
|
|
static constexpr std::initializer_list<TestStruct> VO_I_LIST2 = VO_TEST_ARR2;
|
|
|
|
template<typename T>
|
|
struct get {
|
|
template<std::size_t nr>
|
|
static consteval auto& i_list();
|
|
|
|
template<std::size_t nr>
|
|
static consteval auto & arr();
|
|
|
|
template<std::size_t nr>
|
|
static consteval std::size_t arr_len();
|
|
|
|
template<std::size_t nr>
|
|
static consteval std::size_t capacity();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
template<typename T>
|
|
template<std::size_t nr>
|
|
consteval auto & test_defs::get<T>::i_list() { return nullptr; }
|
|
template<typename T>
|
|
template<std::size_t nr>
|
|
consteval auto & test_defs::get<T>::arr() { return nullptr; }
|
|
template<typename T>
|
|
template<std::size_t nr>
|
|
consteval std::size_t test_defs::get<T>::arr_len() { return 0; }
|
|
template<typename T>
|
|
template<std::size_t nr>
|
|
consteval std::size_t test_defs::get<T>::capacity() { return 0; }
|
|
|
|
|
|
template<> template<> consteval auto & test_defs::get<int>::i_list<1>() { return VI_I_LIST1; }
|
|
template<> template<> consteval auto & test_defs::get<int>::i_list<2>() { return VI_I_LIST2; }
|
|
template<> template<> consteval auto & test_defs::get<char>::i_list<1>() { return VC_I_LIST1; }
|
|
template<> template<> consteval auto & test_defs::get<char>::i_list<2>() { return VC_I_LIST2; }
|
|
template<> template<> consteval auto & test_defs::get<const char *>::i_list<1>() { return VS_I_LIST1; }
|
|
template<> template<> consteval auto & test_defs::get<const char *>::i_list<2>() { return VS_I_LIST2; }
|
|
template<> template<> consteval auto & test_defs::get<TestStruct>::i_list<1>() { return VO_I_LIST1; }
|
|
template<> template<> consteval auto & test_defs::get<TestStruct>::i_list<2>() { return VO_I_LIST2; }
|
|
|
|
template<> template<> consteval auto & test_defs::get<int>::arr<1>() { return C_VI_TEST_ARR1; }
|
|
template<> template<> consteval auto & test_defs::get<int>::arr<2>() { return C_VI_TEST_ARR2; }
|
|
template<> template<> consteval auto & test_defs::get<char>::arr<1>() { return C_VC_TEST_ARR1; }
|
|
template<> template<> consteval auto & test_defs::get<char>::arr<2>() { return C_VC_TEST_ARR2; }
|
|
template<> template<> consteval auto & test_defs::get<const char*>::arr<1>() { return C_VS_TEST_ARR1; }
|
|
template<> template<> consteval auto & test_defs::get<const char*>::arr<2>() { return C_VS_TEST_ARR2; }
|
|
template<> template<> consteval auto & test_defs::get<TestStruct>::arr<1>() { return C_VO_TEST_ARR1; }
|
|
template<> template<> consteval auto & test_defs::get<TestStruct>::arr<2>() { return C_VO_TEST_ARR2; }
|
|
|
|
template<> template<> consteval std::size_t test_defs::get<int>::arr_len<1>() { return VI_TEST_ARR1_LEN; }
|
|
template<> template<> consteval std::size_t test_defs::get<int>::arr_len<2>() { return VI_TEST_ARR2_LEN; }
|
|
template<> template<> consteval std::size_t test_defs::get<char>::arr_len<1>() { return VC_TEST_ARR1_LEN; }
|
|
template<> template<> consteval std::size_t test_defs::get<char>::arr_len<2>() { return VC_TEST_ARR2_LEN; }
|
|
template<> template<> consteval std::size_t test_defs::get<const char *>::arr_len<1>() { return VS_TEST_ARR1_LEN; }
|
|
template<> template<> consteval std::size_t test_defs::get<const char *>::arr_len<2>() { return VS_TEST_ARR2_LEN; }
|
|
template<> template<> consteval std::size_t test_defs::get<TestStruct>::arr_len<1>() { return VO_TEST_ARR1_LEN; }
|
|
template<> template<> consteval std::size_t test_defs::get<TestStruct>::arr_len<2>() { return VO_TEST_ARR2_LEN; }
|
|
|
|
template<> template<> consteval std::size_t test_defs::get<int>::capacity<1>() { return TEST_VEC1_CAPACITY; }
|
|
template<> template<> consteval std::size_t test_defs::get<int>::capacity<2>() { return TEST_VEC2_CAPACITY; }
|
|
template<> template<> consteval std::size_t test_defs::get<char>::capacity<1>() { return TEST_VEC1_CAPACITY; }
|
|
template<> template<> consteval std::size_t test_defs::get<char>::capacity<2>() { return TEST_VEC2_CAPACITY; }
|
|
template<> template<> consteval std::size_t test_defs::get<const char *>::capacity<1>() { return TEST_VEC1_CAPACITY; }
|
|
template<> template<> consteval std::size_t test_defs::get<const char *>::capacity<2>() { return TEST_VEC2_CAPACITY; }
|
|
template<> template<> consteval std::size_t test_defs::get<TestStruct>::capacity<1>() { return TEST_VEC1_CAPACITY; }
|
|
template<> template<> consteval std::size_t test_defs::get<TestStruct>::capacity<2>() { return TEST_VEC2_CAPACITY; }
|
|
|
|
|
|
#endif //UDIFF_TEST_ARGS_H_
|