87 lines
5.9 KiB
C++
87 lines
5.9 KiB
C++
#ifndef CONST_CONTAINER_TEST_ARGS_H
|
|
#define CONST_CONTAINER_TEST_ARGS_H
|
|
|
|
#include "test.hpp"
|
|
|
|
#define GEN_TEST_OBJ_FROM_ARR(nr, i) TestObj(test_context_params<int, nr>::value<"arr">[i], test_context_params<char, nr>::value<"arr">[i], test_context_params<const char *, nr>::value<"arr">[i])
|
|
|
|
struct TestObj {
|
|
int x = 0;
|
|
char c = 0;
|
|
const char * s = "This is a string";
|
|
|
|
constexpr bool operator==(const TestObj &other) const { return x == other.x && c == other.c && std::string_view(s) == other.s; }
|
|
};
|
|
ADD_TYPE_HINT(TestObj);
|
|
|
|
template<> template<> constexpr int test_context_params<int, 0>::value<"arr">[] = { 1, 2, 3, 4 };
|
|
template<> template<> constexpr int test_context_params<int, 1>::value<"arr">[] = { 5, 6, 7, 8, 9, 10, 11, 12 };
|
|
template<> template<> constexpr char test_context_params<char, 0>::value<"arr">[] = { 'a', 'B', 'c', 'D' };
|
|
template<> template<> constexpr char test_context_params<char, 1>::value<"arr">[] = { 'e', 'F', 'g', 'H', 'i', 'J', '\n', '\0' };
|
|
template<> template<> constexpr const char * test_context_params<const char *, 0>::value<"arr">[] = { "Lorem", "ipsum", "dolor", "sit" };
|
|
template<> template<> constexpr const char * test_context_params<const char *, 1>::value<"arr">[] = { "amet", "consetetur", "sadipscing", "elitr", "sed", "diam", "nonumy", "eirmod", "tempor", "\0" };
|
|
template<> template<> constexpr TestObj test_context_params<TestObj, 0>::value<"arr">[] = {
|
|
GEN_TEST_OBJ_FROM_ARR(0, 0),
|
|
GEN_TEST_OBJ_FROM_ARR(0, 1),
|
|
GEN_TEST_OBJ_FROM_ARR(0, 2),
|
|
GEN_TEST_OBJ_FROM_ARR(0, 3) };
|
|
template<> template<> constexpr TestObj test_context_params<TestObj, 1>::value<"arr">[] = {
|
|
GEN_TEST_OBJ_FROM_ARR(1, 0),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 1),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 2),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 3),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 4),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 5),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 6),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 7) };
|
|
|
|
template<> template<> constexpr std::initializer_list<int> test_context_params<int, 0>::value<"ilist"> = { 1, 2, 3, 4 };
|
|
template<> template<> constexpr std::initializer_list<int> test_context_params<int, 1>::value<"ilist"> = { 5, 6, 7, 8, 9, 10, 11, 12 };
|
|
template<> template<> constexpr std::initializer_list<char> test_context_params<char, 0>::value<"ilist"> = { 'a', 'B', 'c', 'D' };
|
|
template<> template<> constexpr std::initializer_list<char> test_context_params<char, 1>::value<"ilist"> = { 'e', 'F', 'g', 'H', 'i', 'J', '\n', '\0' };
|
|
template<> template<> constexpr std::initializer_list<const char *> test_context_params<const char *, 0>::value<"ilist"> = { "Lorem", "ipsum", "dolor", "sit" };
|
|
template<> template<> constexpr std::initializer_list<const char *> test_context_params<const char *, 1>::value<"ilist"> = { "amet", "consetetur", "sadipscing", "elitr", "sed", "diam", "nonumy", "eirmod", "tempor", "\0" };
|
|
template<> template<> constexpr std::initializer_list<TestObj> test_context_params<TestObj, 0>::value<"ilist"> = {
|
|
GEN_TEST_OBJ_FROM_ARR(0, 0),
|
|
GEN_TEST_OBJ_FROM_ARR(0, 1),
|
|
GEN_TEST_OBJ_FROM_ARR(0, 2),
|
|
GEN_TEST_OBJ_FROM_ARR(0, 3) };
|
|
template<> template<> constexpr std::initializer_list<TestObj> test_context_params<TestObj, 1>::value<"ilist"> = {
|
|
GEN_TEST_OBJ_FROM_ARR(1, 0),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 1),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 2),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 3),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 4),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 5),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 6),
|
|
GEN_TEST_OBJ_FROM_ARR(1, 7) };
|
|
|
|
template<> template<> constexpr std::size_t test_context_params<int, 0>::value<"capacity"> = 10;
|
|
template<> template<> constexpr std::size_t test_context_params<char, 0>::value<"capacity"> = 10;
|
|
template<> template<> constexpr std::size_t test_context_params<const char *, 0>::value<"capacity"> = 10;
|
|
template<> template<> constexpr std::size_t test_context_params<TestObj, 0>::value<"capacity"> = 10;
|
|
template<> template<> constexpr std::size_t test_context_params<int, 1>::value<"capacity"> = 200;
|
|
template<> template<> constexpr std::size_t test_context_params<char, 1>::value<"capacity"> = 200;
|
|
template<> template<> constexpr std::size_t test_context_params<const char *, 1>::value<"capacity"> = 200;
|
|
template<> template<> constexpr std::size_t test_context_params<TestObj, 1>::value<"capacity"> = 200;
|
|
|
|
template<> template<> constexpr std::size_t test_context_params<int, 0>::value<"size"> = 25;
|
|
template<> template<> constexpr std::size_t test_context_params<char, 0>::value<"size"> = 25;
|
|
template<> template<> constexpr std::size_t test_context_params<const char *, 0>::value<"size"> = 25;
|
|
template<> template<> constexpr std::size_t test_context_params<TestObj, 0>::value<"size"> = 25;
|
|
template<> template<> constexpr std::size_t test_context_params<int, 1>::value<"size"> = 50;
|
|
template<> template<> constexpr std::size_t test_context_params<char, 1>::value<"size"> = 50;
|
|
template<> template<> constexpr std::size_t test_context_params<const char *, 1>::value<"size"> = 50;
|
|
template<> template<> constexpr std::size_t test_context_params<TestObj, 1>::value<"size"> = 50;
|
|
|
|
template<> template<> constexpr int test_context_params<int, 0>::value<"value"> = 5;
|
|
template<> template<> constexpr int test_context_params<int, 1>::value<"value"> = INT_MIN;
|
|
template<> template<> constexpr char test_context_params<char, 0>::value<"value"> = 'P';
|
|
template<> template<> constexpr char test_context_params<char, 1>::value<"value"> = CHAR_MAX;
|
|
template<> template<> constexpr const char * test_context_params<const char *, 0>::value<"value"> = "Test string 1";
|
|
template<> template<> constexpr const char * test_context_params<const char *, 1>::value<"value"> = "Test string 2";
|
|
template<> template<> constexpr TestObj test_context_params<TestObj, 0>::value<"value"> = TestObj(5, 'P', "Object String 1");
|
|
template<> template<> constexpr TestObj test_context_params<TestObj, 1>::value<"value"> = TestObj(INT_MAX, 'p', "2 Object String");
|
|
|
|
#endif //CONST_CONTAINER_TEST_ARGS_H
|