Compare commits
9 Commits
5e1bda2715
...
4f11db301f
| Author | SHA1 | Date |
|---|---|---|
|
|
4f11db301f | |
|
|
698641718f | |
|
|
fd180efb6c | |
|
|
32ae9a2d3d | |
|
|
c2d828cfb9 | |
|
|
9cbeacef21 | |
|
|
cfb82ca1fe | |
|
|
6ebec36b2d | |
|
|
0350b33087 |
|
|
@ -467,40 +467,48 @@ namespace cc {
|
|||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
template<class... Args>
|
||||
template<typename... Args>
|
||||
constexpr const_vector<T, N>::iterator const_vector<T, N>::emplace(const_vector::const_iterator pos, Args &&... args)
|
||||
{
|
||||
if (_size == N) throw std::exception();
|
||||
if (_size == N) throw std::length_error("No space left in vector");
|
||||
|
||||
T obj(std::forward<Args>(args)...);
|
||||
|
||||
ptrdiff_t i = pos - _arr;
|
||||
std::move(_arr + i, _arr + _size, _arr + i + 1);
|
||||
_erase_no_move(pos);
|
||||
_arr[i] = std::move(obj);
|
||||
|
||||
return pos;
|
||||
auto it = const_cast<iterator>(pos);
|
||||
|
||||
if (it != end()) {
|
||||
std::move_backward(it, end(), end() + 1);
|
||||
}
|
||||
*it = T(std::forward<Args>(args)...);
|
||||
|
||||
++_size;
|
||||
return it;
|
||||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
constexpr const_vector<T, N>::iterator const_vector<T, N>::erase(const_vector::const_iterator pos)
|
||||
{
|
||||
_erase_no_move(pos);
|
||||
std::move(pos + 1, end(), pos);
|
||||
auto it = const_cast<iterator>(pos);
|
||||
|
||||
std::destroy_n(it, 1);
|
||||
std::move(it + 1, end(), it);
|
||||
--_size;
|
||||
|
||||
return pos;
|
||||
return it;
|
||||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
constexpr const_vector<T, N>::iterator
|
||||
const_vector<T, N>::erase(const_vector::const_iterator first, const_vector::const_iterator last)
|
||||
{
|
||||
_erase_no_move(first, last);
|
||||
std::move(last + 1, end(), first);
|
||||
_size -= (last - first);
|
||||
auto _first = const_cast<iterator>(first);
|
||||
auto _last = const_cast<iterator>(last);
|
||||
|
||||
if (_first == _last) return _last;
|
||||
|
||||
std::destroy(_first, _last);
|
||||
std::move(_last, end(), _first);
|
||||
_size -= std::distance(_first, _last);
|
||||
|
||||
return first;
|
||||
return _first;
|
||||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
|
|
@ -519,13 +527,13 @@ namespace cc {
|
|||
template<typename ...Args>
|
||||
constexpr const_vector<T, N>::reference const_vector<T, N>::emplace_back(Args&&... args)
|
||||
{
|
||||
emplace(end(), std::forward(args)...);
|
||||
return *emplace(cend(), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
constexpr void const_vector<T, N>::pop_back()
|
||||
{
|
||||
_erase_no_move(end() - 1, end());
|
||||
std::destroy_n(end() - 1, 1);
|
||||
--_size;
|
||||
}
|
||||
|
||||
|
|
@ -533,9 +541,9 @@ namespace cc {
|
|||
template<std::size_t N2>
|
||||
constexpr void const_vector<T, N>::swap(const_vector<T, N2> &other)
|
||||
{
|
||||
if (_size > other._len || other._size > N) throw std::exception();
|
||||
if (_size > other._len || other._size > N) throw std::invalid_argument("Cannot swap elements, one does not fit into the other");
|
||||
|
||||
cc::helper::swap_iter_range(begin(), end(), std::end(_arr), other.begin(), other.end(), std::end(other._arr));
|
||||
cc::helper::swap_iter_range(begin(), end(), other.begin(), other.end());
|
||||
std::swap(_size, other._size);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ namespace cc::helper {
|
|||
template<typename T, std::size_t N>
|
||||
constexpr std::size_t array_size(const T(&)[N]) { return N; }
|
||||
|
||||
template<std::input_or_output_iterator InputIt1, std::input_or_output_iterator InputIt2, typename T = InputIt1::value_type>
|
||||
requires ((InputIt1::value_type == InputIt2::value_type)
|
||||
&& std::indirectly_writable<typename InputIt1::value_type, InputIt1> && std::indirectly_readable<InputIt1>
|
||||
&& std::indirectly_writable<typename InputIt2::value_type, InputIt1> && std::indirectly_readable<InputIt2>)
|
||||
template<std::input_or_output_iterator InputIt1, std::input_or_output_iterator InputIt2>
|
||||
requires std::is_same_v<typename std::iterator_traits<InputIt1>::value_type, typename std::iterator_traits<InputIt2>::value_type>
|
||||
&& std::indirectly_writable<InputIt1, typename std::iterator_traits<InputIt2>::value_type> && std::indirectly_readable<InputIt1>
|
||||
&& std::indirectly_writable<InputIt2, typename std::iterator_traits<InputIt1>::value_type> && std::indirectly_readable<InputIt2>
|
||||
constexpr void swap_iter_range(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
|
||||
{
|
||||
auto dist1 = std::distance(first1, last1);
|
||||
|
|
@ -31,7 +31,7 @@ namespace cc::helper {
|
|||
|
||||
auto swap_dist = std::min(dist1, dist2);
|
||||
|
||||
std::swap_ranges(first1, std::next(first1, swap_dist), first2, std::next(first2, swap_dist));
|
||||
std::swap_ranges(first1, std::next(first1, swap_dist), first2);
|
||||
|
||||
std::advance(first1, swap_dist);
|
||||
std::advance(first2, swap_dist);
|
||||
|
|
@ -43,10 +43,10 @@ namespace cc::helper {
|
|||
}
|
||||
}
|
||||
|
||||
template<std::input_or_output_iterator InputIt1, std::input_or_output_iterator InputIt2, typename T = InputIt1::value_type>
|
||||
requires ((InputIt1::value_type == InputIt2::value_type)
|
||||
&& std::indirectly_writable<typename InputIt1::value_type, InputIt1> && std::indirectly_readable<InputIt1>
|
||||
&& std::indirectly_writable<typename InputIt2::value_type, InputIt1> && std::indirectly_readable<InputIt2>)
|
||||
template<std::input_or_output_iterator InputIt1, std::input_or_output_iterator InputIt2>
|
||||
requires std::is_same_v<typename std::iterator_traits<InputIt1>::value_type, typename std::iterator_traits<InputIt2>::value_type>
|
||||
&& std::indirectly_writable<InputIt1, typename std::iterator_traits<InputIt2>::value_type> && std::indirectly_readable<InputIt1>
|
||||
&& std::indirectly_writable<InputIt2, typename std::iterator_traits<InputIt1>::value_type> && std::indirectly_readable<InputIt2>
|
||||
constexpr void swap(InputIt1 first1, InputIt1 last1, InputIt1 end1, InputIt2 first2, InputIt2 last2, InputIt2 end2)
|
||||
{
|
||||
auto max_dist = std::min(std::distance(first1, end1), std::distance(first2, end2));
|
||||
|
|
|
|||
|
|
@ -1,58 +1,10 @@
|
|||
#include <const_vector.hpp>
|
||||
|
||||
#include <test.hpp>
|
||||
#include <vector>
|
||||
#include <format>
|
||||
#include "test_params.h"
|
||||
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
#include <sstream>
|
||||
|
||||
template<std::ranges::range R, typename CharT>
|
||||
struct std::formatter<R, CharT> {
|
||||
template<typename ParseContext>
|
||||
constexpr ParseContext::iterator parse(ParseContext& ctx) {
|
||||
auto it = ctx.begin();
|
||||
while (it != ctx.end() && *it != '}')
|
||||
++it;
|
||||
return it;
|
||||
}
|
||||
template<typename FmtContext>
|
||||
constexpr FmtContext::iterator format(const R& range, FmtContext& ctx) const {
|
||||
std::ostringstream out;
|
||||
out << '[';
|
||||
|
||||
auto it = std::ranges::begin(range);
|
||||
for (; it != std::next(std::ranges::begin(range), std::ranges::size(range) - 1); ++it) {
|
||||
out << std::format("{}, ", *it);
|
||||
}
|
||||
out << std::format("{}]", *it);
|
||||
|
||||
return std::ranges::copy(std::move(out).str(), ctx.out()).out;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename CharT>
|
||||
struct std::formatter<TestObj, CharT> {
|
||||
template<typename ParseContext>
|
||||
constexpr ParseContext::iterator parse(ParseContext &ctx)
|
||||
{
|
||||
auto it = ctx.begin();
|
||||
while (it != ctx.end() && *it != '}')
|
||||
++it;
|
||||
return it;
|
||||
}
|
||||
|
||||
template<typename FmtContext>
|
||||
constexpr FmtContext::iterator format(const TestObj &obj, FmtContext &ctx) const
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << '(' << obj.x << ", '" << obj.c << "', \"" << obj.s << "\")";
|
||||
|
||||
return std::ranges::copy(std::move(out).str(), ctx.out()).out;
|
||||
}
|
||||
};
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
constexpr test_suite tests = define_tests("Data Augmentation")
|
||||
("const_vector::clear()", []() constexpr {
|
||||
|
|
@ -222,24 +174,185 @@ constexpr test_suite tests = define_tests("Data Augmentation")
|
|||
|
||||
REPEAT_FOR_TYPES_N(([]<typename T, std::size_t N, typename ctx>() constexpr {
|
||||
|
||||
cc::const_vector<T, get_test_param<ctx, "ilist">().size() * 4> v(get_test_param<ctx, "ilist">());
|
||||
cc::const_vector<T, c_arr_len(get_test_param<ctx, "arr">()) + 3> v(get_test_param<ctx, "arr">());
|
||||
|
||||
auto it = v.emplace();
|
||||
auto value = make_copy(get_test_param<ctx, "value">());
|
||||
auto value_comp = make_copy(get_test_param<ctx, "value">());
|
||||
|
||||
ASSERT_THROWS((v.insert(v.end(), get_test_param<ctx, "ilist">())), std::length_error, ctx);
|
||||
typename decltype(v)::iterator it;
|
||||
if constexpr(!std::is_same_v<T, TestObj>) {
|
||||
it = v.emplace(std::next(v.begin()), get_test_param<ctx, "arr">()[0]);
|
||||
} else {
|
||||
auto obj = get_test_param<ctx, "arr">()[0];
|
||||
it = v.emplace(std::next(v.begin()), obj.x, obj.c, obj.s);
|
||||
}
|
||||
|
||||
v.emplace(it, force_move(value));
|
||||
|
||||
if constexpr (!std::is_same_v<T, const char*>) {
|
||||
v.emplace(v.end(), T());
|
||||
} else {
|
||||
v.emplace(v.end(), "");
|
||||
}
|
||||
|
||||
ASSERT_THROWS((v.emplace(v.end(), T())), std::length_error, ctx);
|
||||
|
||||
std::vector<T> comparable;
|
||||
std::ranges::copy(get_test_param<ctx, "arr">(), std::back_inserter(comparable));
|
||||
|
||||
auto cit = comparable.insert(std::next(comparable.begin()), get_test_param<ctx, "ilist">());
|
||||
comparable.insert(cit, get_test_param<ctx, "ilist">());
|
||||
comparable.insert(comparable.end(), get_test_param<ctx, "ilist">());
|
||||
typename decltype(comparable)::iterator cit;
|
||||
if constexpr(!std::is_same_v<T, TestObj>) {
|
||||
cit = comparable.emplace(std::next(comparable.begin()), get_test_param<ctx, "arr">()[0]);
|
||||
} else {
|
||||
auto obj = get_test_param<ctx, "arr">()[0];
|
||||
cit = comparable.emplace(std::next(comparable.begin()), obj.x, obj.c, obj.s);
|
||||
}
|
||||
|
||||
comparable.emplace(cit, force_move(value_comp));
|
||||
|
||||
if constexpr (!std::is_same_v<T, const char *>) {
|
||||
comparable.emplace(comparable.end(), T());
|
||||
} else {
|
||||
comparable.emplace(comparable.end(), "");
|
||||
}
|
||||
|
||||
ASSERT(ranges_equal(v, comparable), ctx);
|
||||
|
||||
return TEST_PASS();
|
||||
}), 2, int, char, const char *, TestObj);
|
||||
|
||||
return TEST_PASS();
|
||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
||||
|
||||
("const_vector::erase()", []() constexpr {
|
||||
|
||||
REPEAT_FOR_TYPES_N(([]<typename T, std::size_t N, typename ctx>() constexpr {
|
||||
|
||||
cc::const_vector v = get_test_param<ctx, "arr">();
|
||||
|
||||
ASSERT(v.erase(std::next(v.begin())) == std::next(v.begin()), ctx);
|
||||
|
||||
ASSERT(v.erase(std::next(v.begin()), v.end()) == v.end(), ctx);
|
||||
ASSERT(v.erase(v.begin(), v.begin()) == v.begin(), ctx);
|
||||
|
||||
std::vector<T> comparable;
|
||||
std::ranges::copy(get_test_param<ctx, "arr">(), std::back_inserter(comparable));
|
||||
|
||||
comparable.erase(std::next(comparable.begin()));
|
||||
comparable.erase(std::next(comparable.begin()), comparable.end());
|
||||
comparable.erase(comparable.begin(), comparable.begin());
|
||||
|
||||
ASSERT(std::ranges::equal(v, comparable), ctx);
|
||||
|
||||
return TEST_PASS();
|
||||
}), 2, int, char, const char *, TestObj);
|
||||
|
||||
return TEST_PASS();
|
||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
||||
|
||||
("const_vector::push_back()", []() constexpr {
|
||||
|
||||
REPEAT_FOR_TYPES_N(([]<typename T, std::size_t N, typename ctx>() constexpr {
|
||||
|
||||
auto value = make_copy(get_test_param<ctx, "value">());
|
||||
|
||||
cc::const_vector<T, 3> v;
|
||||
|
||||
if constexpr (!std::is_same_v<T, const char*>) {
|
||||
v.push_back(T());
|
||||
} else {
|
||||
v.push_back("");
|
||||
}
|
||||
v.push_back(value);
|
||||
v.push_back(force_move(value));
|
||||
|
||||
ASSERT_THROWS(v.push_back(get_test_param<ctx, "value">()), std::length_error, ctx);
|
||||
|
||||
if constexpr (!std::is_same_v<T, const char*>) {
|
||||
ASSERT(v[0] == T());
|
||||
} else {
|
||||
ASSERT(v[0] == std::string_view(""));
|
||||
}
|
||||
ASSERT((v[1] == get_test_param<ctx, "value">()), ctx);
|
||||
ASSERT((v[2] == get_test_param<ctx, "value">()), ctx);
|
||||
|
||||
ASSERT(v.size() == 3);
|
||||
|
||||
return TEST_PASS();
|
||||
}), 2, int, char, const char *, TestObj);
|
||||
|
||||
return TEST_PASS();
|
||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
||||
("const_vector::emplace_back()", []() constexpr {
|
||||
|
||||
REPEAT_FOR_TYPES_N(([]<typename T, std::size_t N, typename ctx>() constexpr {
|
||||
|
||||
auto value = make_copy(get_test_param<ctx, "value">());
|
||||
|
||||
cc::const_vector<T, 3> v;
|
||||
|
||||
if constexpr (!std::is_same_v<T, const char*>) {
|
||||
ASSERT(&v.emplace_back(T()) == v.begin(), ctx);
|
||||
} else {
|
||||
ASSERT(&v.emplace_back("") == v.begin(), ctx);
|
||||
}
|
||||
if constexpr (!std::is_same_v<T, TestObj>) {
|
||||
ASSERT(&v.emplace_back(value) == std::next(v.begin()), ctx);
|
||||
} else {
|
||||
ASSERT(&v.emplace_back(value.x, value.c, value.s) == std::next(v.begin()), ctx);
|
||||
}
|
||||
ASSERT(&v.emplace_back(force_move(value)) == std::next(v.begin(), 2), ctx);
|
||||
|
||||
ASSERT_THROWS(v.emplace_back(get_test_param<ctx, "value">()), std::length_error, ctx);
|
||||
|
||||
if constexpr (!std::is_same_v<T, const char*>) {
|
||||
ASSERT(v[0] == T());
|
||||
} else {
|
||||
ASSERT(v[0] == std::string_view(""));
|
||||
}
|
||||
ASSERT((v[1] == get_test_param<ctx, "value">()), ctx);
|
||||
ASSERT((v[2] == get_test_param<ctx, "value">()), ctx);
|
||||
|
||||
ASSERT(v.size() == 3);
|
||||
|
||||
return TEST_PASS();
|
||||
}), 2, int, char, const char *, TestObj);
|
||||
|
||||
return TEST_PASS();
|
||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
||||
("const_vector::pop_back()", []() constexpr {
|
||||
|
||||
REPEAT_FOR_TYPES_N(([]<typename T, std::size_t N, typename ctx>() constexpr {
|
||||
|
||||
cc::const_vector v(get_test_param<ctx, "arr">());
|
||||
|
||||
v.pop_back();
|
||||
|
||||
auto& arr = get_test_param<ctx, "arr">();
|
||||
ASSERT(std::ranges::equal(v, arr | std::ranges::views::take(c_arr_len(arr) - 1)), ctx);
|
||||
|
||||
return TEST_PASS();
|
||||
}), 2, int, char, const char *, TestObj);
|
||||
|
||||
return TEST_PASS();
|
||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
||||
|
||||
("const_vector::swap()", []() constexpr {
|
||||
|
||||
REPEAT_FOR_TYPES_N(([]<typename T, std::size_t N, typename ctx>() constexpr {
|
||||
|
||||
cc::const_vector va(get_test_param<ctx, "arr">());
|
||||
cc::const_vector<T, get_test_param<ctx, "capacity">()> vv(c_arr_len(get_test_param<ctx, "arr">()), get_test_param<ctx, "value">());
|
||||
|
||||
va.swap(vv);
|
||||
|
||||
ASSERT(all_equal_to(va, get_test_param<ctx, "value">()));
|
||||
ASSERT(va.size() == c_arr_len(get_test_param<ctx, "arr">()), ctx);
|
||||
ASSERT(std::ranges::equal(vv, get_test_param<ctx, "arr">()), ctx);
|
||||
|
||||
return TEST_PASS();
|
||||
}), 2, int, char, const char *, TestObj);
|
||||
|
||||
return TEST_PASS();
|
||||
}, EvalFlag::RUNTIME_CONSTEVAL);
|
||||
|
||||
|
|
|
|||
|
|
@ -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