removed test_args
This commit is contained in:
parent
698641718f
commit
4f11db301f
|
|
@ -1,179 +0,0 @@
|
|||
#ifndef UDIFF_TEST_ARGS_H_
|
||||
#define UDIFF_TEST_ARGS_H_
|
||||
|
||||
#include <array>
|
||||
#include <initializer_list>
|
||||
|
||||
#include <test.hpp>
|
||||
|
||||
#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; }
|
||||
};
|
||||
ADD_TYPE_HINT(TestStruct);
|
||||
|
||||
struct test_defs {
|
||||
|
||||
#define GEN_TEST_STRUCT_ARR(nr, i) TestStruct(test_defs::get<int>::arr<nr>[i], test_defs::get<char>::arr<nr>[i], test_defs::get<const char *>::arr<nr>[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<typename T>
|
||||
struct get {
|
||||
template<std::size_t nr>
|
||||
static constexpr T arr[] = {};
|
||||
|
||||
template<std::size_t nr>
|
||||
static constexpr std::initializer_list<T> i_list = {};
|
||||
|
||||
template<std::size_t nr>
|
||||
static consteval std::size_t arr_len();
|
||||
|
||||
template<std::size_t nr>
|
||||
static consteval std::size_t il_len();
|
||||
|
||||
template<std::size_t nr>
|
||||
static consteval std::size_t capacity();
|
||||
|
||||
template<std::size_t nr>
|
||||
static consteval std::size_t size();
|
||||
|
||||
template<std::size_t nr>
|
||||
static consteval T value();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
template<> template<> constexpr int test_defs::get<int>::arr<1>[] = { 1, 2, 3, 4 };
|
||||
template<> template<> constexpr int test_defs::get<int>::arr<2>[] = { 5, 6, 7, 8, 9, 10, 11, 12 };
|
||||
template<> template<> constexpr char test_defs::get<char>::arr<1>[] = { 'a', 'B', 'c', 'D' };
|
||||
template<> template<> constexpr char test_defs::get<char>::arr<2>[] = { 'e', 'F', 'g', 'H', 'i', 'J', '\n', '\0' };
|
||||
template<> template<> constexpr const char * test_defs::get<const char*>::arr<1>[] = { "Lorem", "ipsum", "dolor", "sit" };
|
||||
template<> template<> constexpr const char * test_defs::get<const char*>::arr<2>[] = { "amet", "consetetur", "sadipscing", "elitr", "sed", "diam", "nonumy", "eirmod", "tempor", "\0" };
|
||||
template<> template<> constexpr TestStruct test_defs::get<TestStruct>::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<TestStruct>::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<int> test_defs::get<int>::i_list<1> = { 1, 2, 3, 4 };
|
||||
template<> template<> constexpr std::initializer_list<int> test_defs::get<int>::i_list<2> = { 5, 6, 7, 8, 9, 10, 11, 12 };
|
||||
template<> template<> constexpr std::initializer_list<char> test_defs::get<char>::i_list<1> = { 'a', 'B', 'c', 'D' };
|
||||
template<> template<> constexpr std::initializer_list<char> test_defs::get<char>::i_list<2> = { 'e', 'F', 'g', 'H', 'i', 'J', '\n', '\0' };
|
||||
template<> template<> constexpr std::initializer_list<const char *> test_defs::get<const char *>::i_list<1> = { "Lorem", "ipsum", "dolor", "sit" };
|
||||
template<> template<> constexpr std::initializer_list<const char *> test_defs::get<const char *>::i_list<2> = { "amet", "consetetur", "sadipscing", "elitr", "sed", "diam", "nonumy", "eirmod", "tempor", "\0" };
|
||||
template<> template<> constexpr std::initializer_list<TestStruct> test_defs::get<TestStruct>::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<TestStruct> test_defs::get<TestStruct>::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<typename T>
|
||||
template<std::size_t nr>
|
||||
consteval std::size_t test_defs::get<T>::arr_len() { return C_ARR_LEN(arr<nr>); }
|
||||
template<typename T>
|
||||
template<std::size_t nr>
|
||||
consteval std::size_t test_defs::get<T>::il_len() { return i_list<nr>.size(); }
|
||||
template<typename T>
|
||||
template<std::size_t nr>
|
||||
consteval std::size_t test_defs::get<T>::capacity() { return 0; }
|
||||
template<typename T>
|
||||
template<std::size_t nr>
|
||||
consteval T test_defs::get<T>::value() { return T(); }
|
||||
|
||||
/*template<> template<> consteval auto & test_defs::get<int>::arr<1>() { return arr<1>; }
|
||||
template<> template<> consteval auto & test_defs::get<int>::arr<2>() { return arr<2>; }
|
||||
template<> template<> consteval auto & test_defs::get<char>::arr<1>() { return arr<1>; }
|
||||
template<> template<> consteval auto & test_defs::get<char>::arr<2>() { return arr<2>; }
|
||||
template<> template<> consteval auto & test_defs::get<const char*>::arr<1>() { return arr<1>; }
|
||||
template<> template<> consteval auto & test_defs::get<const char*>::arr<2>() { return arr<2>; }
|
||||
template<> template<> consteval auto & test_defs::get<TestStruct>::arr<1>() { return arr<1>; }
|
||||
template<> template<> consteval auto & test_defs::get<TestStruct>::arr<2>() { return arr<2>; }
|
||||
|
||||
template<> template<> consteval std::size_t test_defs::get<int>::arr_len<1>() { return C_ARR_LEN(arr<1>()); }
|
||||
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; }
|
||||
|
||||
template<> template<> consteval std::size_t test_defs::get<int>::size<1>() { return TEST_VEC1_SIZE; }
|
||||
template<> template<> consteval std::size_t test_defs::get<int>::size<2>() { return TEST_VEC2_SIZE; }
|
||||
template<> template<> consteval std::size_t test_defs::get<char>::size<1>() { return TEST_VEC1_SIZE; }
|
||||
template<> template<> consteval std::size_t test_defs::get<char>::size<2>() { return TEST_VEC2_SIZE; }
|
||||
template<> template<> consteval std::size_t test_defs::get<const char *>::size<1>() { return TEST_VEC1_SIZE; }
|
||||
template<> template<> consteval std::size_t test_defs::get<const char *>::size<2>() { return TEST_VEC2_SIZE; }
|
||||
template<> template<> consteval std::size_t test_defs::get<TestStruct>::size<1>() { return TEST_VEC1_SIZE; }
|
||||
template<> template<> consteval std::size_t test_defs::get<TestStruct>::size<2>() { return TEST_VEC2_SIZE; }
|
||||
|
||||
template<> template<> consteval int test_defs::get<int>::value<1>() { return 5; }
|
||||
template<> template<> consteval int test_defs::get<int>::value<2>() { return INT_MIN; }
|
||||
template<> template<> consteval char test_defs::get<char>::value<1>() { return 'P'; }
|
||||
template<> template<> consteval char test_defs::get<char>::value<2>() { return CHAR_MAX; }
|
||||
template<> template<> consteval const char * test_defs::get<const char *>::value<1>() { return "Test string 1"; }
|
||||
template<> template<> consteval const char * test_defs::get<const char *>::value<2>() { return "Test string 2"; }
|
||||
template<> template<> consteval TestStruct test_defs::get<TestStruct>::value<1>() { return TestStruct(5, 'P', "Object String 1"); }
|
||||
template<> template<> consteval TestStruct test_defs::get<TestStruct>::value<2>() { return TestStruct(INT_MAX, 'p', "2 Object String"); }
|
||||
|
||||
#endif //UDIFF_TEST_ARGS_H_
|
||||
Loading…
Reference in New Issue