#ifndef UDIFF_TEST_ARGS_H_ #define UDIFF_TEST_ARGS_H_ #include #include #define C_ARR_LEN(arr) (sizeof(arr)/sizeof(arr[0])) struct TestStruct { int x = 0; char c = 0; const char * s = "This is a string"; constexpr bool operator==(const TestStruct &other) const { return x == other.x && c == other.c && std::string_view(s) == other.s; } }; struct test_defs { #define GEN_TEST_STRUCT_ARR(nr, i) TestStruct(test_defs::get::arr[i], test_defs::get::arr[i], test_defs::get::arr[i]) #define TEST_VEC1_CAPACITY 5 #define TEST_VEC2_CAPACITY 10 #define TEST_VEC1_SIZE 3 #define TEST_VEC2_SIZE 7 /*#define { 1, 2, 3, 4 } { 1, 2, 3, 4 } #define { 5, 6, 7, 8, 9, 10, 11, 12 } { 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) }*/ template struct get { template static constexpr T arr[] = {}; template static constexpr std::initializer_list i_list = {}; template static consteval std::size_t arr_len(); template static consteval std::size_t il_len(); template static consteval std::size_t capacity(); template static consteval std::size_t size(); template static consteval T value(); }; }; template<> template<> constexpr int test_defs::get::arr<1>[] = { 1, 2, 3, 4 }; template<> template<> constexpr int test_defs::get::arr<2>[] = { 5, 6, 7, 8, 9, 10, 11, 12 }; template<> template<> constexpr char test_defs::get::arr<1>[] = { 'a', 'B', 'c', 'D' }; template<> template<> constexpr char test_defs::get::arr<2>[] = { 'e', 'F', 'g', 'H', 'i', 'J', '\n', '\0' }; template<> template<> constexpr const char * test_defs::get::arr<1>[] = { "Lorem", "ipsum", "dolor", "sit" }; template<> template<> constexpr const char * test_defs::get::arr<2>[] = { "amet", "consetetur", "sadipscing", "elitr", "sed", "diam", "nonumy", "eirmod", "tempor", "\0" }; template<> template<> constexpr TestStruct test_defs::get::arr<1>[] = { GEN_TEST_STRUCT_ARR(1, 0), GEN_TEST_STRUCT_ARR(1, 1), GEN_TEST_STRUCT_ARR(1, 2), GEN_TEST_STRUCT_ARR(1, 3) }; template<> template<> constexpr TestStruct test_defs::get::arr<2>[] = { 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) }; template<> template<> constexpr std::initializer_list test_defs::get::i_list<1> = { 1, 2, 3, 4 }; template<> template<> constexpr std::initializer_list test_defs::get::i_list<2> = { 5, 6, 7, 8, 9, 10, 11, 12 }; template<> template<> constexpr std::initializer_list test_defs::get::i_list<1> = { 'a', 'B', 'c', 'D' }; template<> template<> constexpr std::initializer_list test_defs::get::i_list<2> = { 'e', 'F', 'g', 'H', 'i', 'J', '\n', '\0' }; template<> template<> constexpr std::initializer_list test_defs::get::i_list<1> = { "Lorem", "ipsum", "dolor", "sit" }; template<> template<> constexpr std::initializer_list test_defs::get::i_list<2> = { "amet", "consetetur", "sadipscing", "elitr", "sed", "diam", "nonumy", "eirmod", "tempor", "\0" }; template<> template<> constexpr std::initializer_list test_defs::get::i_list<1> = { GEN_TEST_STRUCT_ARR(1, 0), GEN_TEST_STRUCT_ARR(1, 1), GEN_TEST_STRUCT_ARR(1, 2), GEN_TEST_STRUCT_ARR(1, 3) }; template<> template<> constexpr std::initializer_list test_defs::get::i_list<2> = { 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) }; template template consteval std::size_t test_defs::get::arr_len() { return C_ARR_LEN(arr); } template template consteval std::size_t test_defs::get::il_len() { return i_list.size(); } template template consteval std::size_t test_defs::get::capacity() { return 0; } template template consteval T test_defs::get::value() { return T(); } /*template<> template<> consteval auto & test_defs::get::arr<1>() { return arr<1>; } template<> template<> consteval auto & test_defs::get::arr<2>() { return arr<2>; } template<> template<> consteval auto & test_defs::get::arr<1>() { return arr<1>; } template<> template<> consteval auto & test_defs::get::arr<2>() { return arr<2>; } template<> template<> consteval auto & test_defs::get::arr<1>() { return arr<1>; } template<> template<> consteval auto & test_defs::get::arr<2>() { return arr<2>; } template<> template<> consteval auto & test_defs::get::arr<1>() { return arr<1>; } template<> template<> consteval auto & test_defs::get::arr<2>() { return arr<2>; } template<> template<> consteval std::size_t test_defs::get::arr_len<1>() { return C_ARR_LEN(arr<1>()); } template<> template<> consteval std::size_t test_defs::get::arr_len<2>() { return VI_TEST_ARR2_LEN; } template<> template<> consteval std::size_t test_defs::get::arr_len<1>() { return VC_TEST_ARR1_LEN; } template<> template<> consteval std::size_t test_defs::get::arr_len<2>() { return VC_TEST_ARR2_LEN; } template<> template<> consteval std::size_t test_defs::get::arr_len<1>() { return VS_TEST_ARR1_LEN; } template<> template<> consteval std::size_t test_defs::get::arr_len<2>() { return VS_TEST_ARR2_LEN; } template<> template<> consteval std::size_t test_defs::get::arr_len<1>() { return VO_TEST_ARR1_LEN; } template<> template<> consteval std::size_t test_defs::get::arr_len<2>() { return VO_TEST_ARR2_LEN; }*/ template<> template<> consteval std::size_t test_defs::get::capacity<1>() { return TEST_VEC1_CAPACITY; } template<> template<> consteval std::size_t test_defs::get::capacity<2>() { return TEST_VEC2_CAPACITY; } template<> template<> consteval std::size_t test_defs::get::capacity<1>() { return TEST_VEC1_CAPACITY; } template<> template<> consteval std::size_t test_defs::get::capacity<2>() { return TEST_VEC2_CAPACITY; } template<> template<> consteval std::size_t test_defs::get::capacity<1>() { return TEST_VEC1_CAPACITY; } template<> template<> consteval std::size_t test_defs::get::capacity<2>() { return TEST_VEC2_CAPACITY; } template<> template<> consteval std::size_t test_defs::get::capacity<1>() { return TEST_VEC1_CAPACITY; } template<> template<> consteval std::size_t test_defs::get::capacity<2>() { return TEST_VEC2_CAPACITY; } template<> template<> consteval std::size_t test_defs::get::size<1>() { return TEST_VEC1_SIZE; } template<> template<> consteval std::size_t test_defs::get::size<2>() { return TEST_VEC2_SIZE; } template<> template<> consteval std::size_t test_defs::get::size<1>() { return TEST_VEC1_SIZE; } template<> template<> consteval std::size_t test_defs::get::size<2>() { return TEST_VEC2_SIZE; } template<> template<> consteval std::size_t test_defs::get::size<1>() { return TEST_VEC1_SIZE; } template<> template<> consteval std::size_t test_defs::get::size<2>() { return TEST_VEC2_SIZE; } template<> template<> consteval std::size_t test_defs::get::size<1>() { return TEST_VEC1_SIZE; } template<> template<> consteval std::size_t test_defs::get::size<2>() { return TEST_VEC2_SIZE; } template<> template<> consteval int test_defs::get::value<1>() { return 5; } template<> template<> consteval int test_defs::get::value<2>() { return INT_MIN; } template<> template<> consteval char test_defs::get::value<1>() { return 'P'; } template<> template<> consteval char test_defs::get::value<2>() { return CHAR_MAX; } template<> template<> consteval const char * test_defs::get::value<1>() { return "Test string 1"; } template<> template<> consteval const char * test_defs::get::value<2>() { return "Test string 2"; } template<> template<> consteval TestStruct test_defs::get::value<1>() { return TestStruct(5, 'P', "Object String 1"); } template<> template<> consteval TestStruct test_defs::get::value<2>() { return TestStruct(INT_MAX, 'p', "2 Object String"); } #endif //UDIFF_TEST_ARGS_H_