Compare commits
No commits in common. "6a05192db3868eb935b3bb3b6053cc02f13b2b1f" and "40d4608477bb19df9e9b4fe57685b0a8c7562079" have entirely different histories.
6a05192db3
...
40d4608477
|
|
@ -45,8 +45,6 @@ namespace cc {
|
||||||
constexpr const_vector(size_type count, const value_type &value) noexcept;
|
constexpr const_vector(size_type count, const value_type &value) noexcept;
|
||||||
|
|
||||||
constexpr explicit const_vector(const value_type (&array)[N]) noexcept;
|
constexpr explicit const_vector(const value_type (&array)[N]) noexcept;
|
||||||
template <std::size_t N2>
|
|
||||||
constexpr explicit const_vector(const value_type (&array)[N2]) noexcept;
|
|
||||||
|
|
||||||
constexpr const_vector(std::initializer_list<value_type> values) noexcept;
|
constexpr const_vector(std::initializer_list<value_type> values) noexcept;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,6 @@ set(CMAKE_CXX_STANDARD 23)
|
||||||
add_library(test_common INTERFACE)
|
add_library(test_common INTERFACE)
|
||||||
target_include_directories(test_common INTERFACE common_helper)
|
target_include_directories(test_common INTERFACE common_helper)
|
||||||
target_link_libraries(test_common INTERFACE const_container)
|
target_link_libraries(test_common INTERFACE const_container)
|
||||||
# target_compile_options(test_common INTERFACE -fconcepts-diagnostics-depth=2) # for debugging
|
target_compile_options(test_common INTERFACE -fconcepts-diagnostics-depth=2) # for debugging
|
||||||
|
|
||||||
add_subdirectory(const_vector)
|
add_subdirectory(const_vector)
|
||||||
|
|
|
||||||
|
|
@ -18,29 +18,6 @@
|
||||||
#define TEST_PASS_MSG(msg) ret_val_s { "", ReturnCode::PASSED, msg }
|
#define TEST_PASS_MSG(msg) ret_val_s { "", ReturnCode::PASSED, msg }
|
||||||
#define TEST_SKIP() ret_val_s { "", ReturnCode::SKIPPED, nullptr }
|
#define TEST_SKIP() ret_val_s { "", ReturnCode::SKIPPED, nullptr }
|
||||||
|
|
||||||
#define ASSERT(condition) ASSERT_MSG(condition, #condition)
|
|
||||||
#define ASSERT_MSG(condition, msg) { if (!(condition)) return TEST_FAIL(msg); } static_assert(true, "")
|
|
||||||
#define ASSERT_ALL_EQ(first, last, eq) ASSERT_MSG(std::all_of(first, last, all_eq_arr_elem_test_func(eq)), "Not all elements in (" #first ", " #last ") equal " #eq)
|
|
||||||
#define ASSERT_C_ARR_EQ(first, last, eq) ASSERT_MSG(std::equal(first, last, eq, all_eq_arr_arr_test_func<decltype(eq)>()), "Elements in (" #first ", " #last ") and " #eq " differ")
|
|
||||||
#define ASSERT_ITER_EQ(first, last, eq) ASSERT_MSG(std::equal(first, last, (eq).begin(), all_eq_arr_arr_test_func<std::iterator_traits<decltype(eq)::iterator>::value_type>()), "Elements in (" #first ", " #last ") and " #eq " differ")
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
constexpr auto all_eq_arr_elem_test_func(T&& eq) {
|
|
||||||
return [=] (auto&& e) constexpr { return e == eq; };
|
|
||||||
}
|
|
||||||
template<const char *>
|
|
||||||
constexpr auto all_eq_arr_elem_test_func(const char* eq) {
|
|
||||||
return [=] (auto&& e) constexpr { return std::string_view(e) == eq; };
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
constexpr auto all_eq_arr_arr_test_func() {
|
|
||||||
return [] (auto&& a, auto&& b) constexpr { return a == b; };
|
|
||||||
}
|
|
||||||
template<const char *>
|
|
||||||
constexpr auto all_eq_arr_arr_test_func() {
|
|
||||||
return [] (auto&& a, auto&& b) constexpr { return std::string_view(a) == b; };
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class EvalFlag { RUNTIME, CONSTEVAL, RUNTIME_CONSTEVAL };
|
enum class EvalFlag { RUNTIME, CONSTEVAL, RUNTIME_CONSTEVAL };
|
||||||
enum class ReturnCode { FAILED = -1, PASSED = 0, SKIPPED = 1, NOT_EVALUATED = 2 };
|
enum class ReturnCode { FAILED = -1, PASSED = 0, SKIPPED = 1, NOT_EVALUATED = 2 };
|
||||||
|
|
@ -247,9 +224,4 @@ inline std::ostream& operator<<(std::ostream& os, ReturnCode rc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <template<typename T, std::initializer_list<T> il> typename Callee>
|
|
||||||
constexpr void expand_from_ilist() {
|
|
||||||
return Callee { };
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //CONST_CONTAINER_TEST_HPP_
|
#endif //CONST_CONTAINER_TEST_HPP_
|
||||||
|
|
|
||||||
|
|
@ -2,591 +2,32 @@
|
||||||
|
|
||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
|
|
||||||
#include "test_args.h"
|
|
||||||
|
|
||||||
#define ASSERT_ALL_VEC_EQ(vec, eq) ASSERT_ALL_EQ((vec).begin(), (vec).end(), eq)
|
|
||||||
#define ASSERT_RANGE_VEC_EQ(vec, startI, endI, eq) ASSERT_ALL_EQ(((vec).data() + startI), ((vec).data() + endI), eq)
|
|
||||||
#define ASSERT_VEC_ARR_EQ(vec, eq) ASSERT_C_ARR_EQ((vec).data(), (vec).data() + (vec).size(), eq)
|
|
||||||
#define ASSERT_VEC_EQ(vec1, vec2) ASSERT_C_ARR_EQ((vec1).data(), (vec1).data() + (vec1).size(), (vec2).data())
|
|
||||||
#define ASSERT_RANGE_VEC_ARR_EQ(vec, startI, endI, eq) ASSERT_C_ARR_EQ(((vec).begin() + startI), ((vec).begin() + endI), (eq))
|
|
||||||
|
|
||||||
constexpr test_suite tests = define_tests("Tests")
|
constexpr test_suite tests = define_tests("Tests")
|
||||||
("const_vector()", []() constexpr {
|
("Test Runtime", [](int = 1) constexpr{
|
||||||
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<1>()> vi1;
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<2>()> vi2;
|
|
||||||
|
|
||||||
ASSERT(vi1.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vi2.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vi1.size() == 0);
|
|
||||||
ASSERT(vi2.size() == 0);
|
|
||||||
ASSERT(vi1.empty());
|
|
||||||
ASSERT(vi2.empty());
|
|
||||||
ASSERT_ALL_VEC_EQ(vi1, int());
|
|
||||||
ASSERT_ALL_VEC_EQ(vi2, int());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector<char, test_defs::get<char>::capacity<1>()> vc1;
|
|
||||||
cc::const_vector<char, test_defs::get<char>::capacity<2>()> vc2;
|
|
||||||
|
|
||||||
ASSERT(vc1.capacity() == test_defs::get<char>::capacity<1>());
|
|
||||||
ASSERT(vc2.capacity() == test_defs::get<char>::capacity<2>());
|
|
||||||
ASSERT(vc1.size() == 0);
|
|
||||||
ASSERT(vc2.size() == 0);
|
|
||||||
ASSERT(vc1.empty());
|
|
||||||
ASSERT(vc2.empty());
|
|
||||||
ASSERT_ALL_VEC_EQ(vc1, char());
|
|
||||||
ASSERT_ALL_VEC_EQ(vc2, char());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector<const char *, test_defs::get<const char*>::capacity<1>()> vs1;
|
|
||||||
cc::const_vector<const char *, test_defs::get<const char*>::capacity<2>()> vs2;
|
|
||||||
|
|
||||||
ASSERT(vs1.capacity() == test_defs::get<const char*>::capacity<1>());
|
|
||||||
ASSERT(vs2.capacity() == test_defs::get<const char*>::capacity<2>());
|
|
||||||
ASSERT(vs1.size() == 0);
|
|
||||||
ASSERT(vs2.size() == 0);
|
|
||||||
ASSERT(vs1.empty());
|
|
||||||
ASSERT(vs2.empty());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<TestStruct>::capacity<1>()> vo1;
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<TestStruct>::capacity<2>()> vo2;
|
|
||||||
|
|
||||||
ASSERT(vo1.capacity() == test_defs::get<TestStruct>::capacity<1>());
|
|
||||||
ASSERT(vo2.capacity() == test_defs::get<TestStruct>::capacity<2>());
|
|
||||||
ASSERT(vo1.size() == 0);
|
|
||||||
ASSERT(vo2.size() == 0);
|
|
||||||
ASSERT(vo1.empty());
|
|
||||||
ASSERT(vo2.empty());
|
|
||||||
ASSERT_ALL_VEC_EQ(vo1, TestStruct{});
|
|
||||||
ASSERT_ALL_VEC_EQ(vo2, TestStruct{});
|
|
||||||
|
|
||||||
return TEST_PASS();
|
return TEST_PASS();
|
||||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
}, EvalFlag::RUNTIME)
|
||||||
|
("Test Consteval 1", [](char = 2) constexpr {
|
||||||
|
if (std::is_constant_evaluated()) {
|
||||||
("const_vector(T &value)", []() constexpr {
|
return TEST_PASS();
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<1>()> vi1(test_defs::get<int>::value<1>());
|
} else {
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<2>()> vi2(test_defs::get<int>::value<2>());
|
return TEST_FAIL("FAIL");
|
||||||
|
}
|
||||||
ASSERT(vi1.capacity() == test_defs::get<int>::capacity<1>());
|
}, EvalFlag::CONSTEVAL)
|
||||||
ASSERT(vi2.capacity() == test_defs::get<int>::capacity<2>());
|
("Test Consteval", [](char = 2) constexpr {
|
||||||
ASSERT(vi1.size() == test_defs::get<char>::capacity<1>());
|
if (std::is_constant_evaluated()) {
|
||||||
ASSERT(vi2.size() == test_defs::get<char>::capacity<2>());
|
return TEST_SKIP();
|
||||||
ASSERT_ALL_VEC_EQ(vi1, test_defs::get<int>::value<1>());
|
} else {
|
||||||
ASSERT_ALL_VEC_EQ(vi2, test_defs::get<int>::value<2>());
|
return TEST_FAIL("FAIL");
|
||||||
|
}
|
||||||
|
}, EvalFlag::CONSTEVAL)
|
||||||
cc::const_vector<char, test_defs::get<char>::capacity<1>()> vc1(test_defs::get<char>::value<1>());
|
("Test Runtime Consteval", [](short = 3) constexpr{
|
||||||
cc::const_vector<char, test_defs::get<char>::capacity<2>()> vc2(test_defs::get<char>::value<2>());
|
if (std::is_constant_evaluated()) {
|
||||||
|
return TEST_SKIP();
|
||||||
ASSERT(vc1.capacity() == test_defs::get<char>::capacity<1>());
|
} else {
|
||||||
ASSERT(vc2.capacity() == test_defs::get<char>::capacity<2>());
|
return TEST_PASS();
|
||||||
ASSERT(vc1.size() == test_defs::get<char>::capacity<1>());
|
}
|
||||||
ASSERT(vc2.size() == test_defs::get<char>::capacity<2>());
|
}, EvalFlag::RUNTIME_CONSTEVAL);
|
||||||
ASSERT_ALL_VEC_EQ(vc1, test_defs::get<char>::value<1>());
|
|
||||||
ASSERT_ALL_VEC_EQ(vc2, test_defs::get<char>::value<2>());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector<const char *, test_defs::get<const char *>::capacity<1>()> vs1(test_defs::get<const char *>::value<1>());
|
|
||||||
cc::const_vector<const char *, test_defs::get<const char *>::capacity<2>()> vs2(test_defs::get<const char *>::value<2>());
|
|
||||||
|
|
||||||
ASSERT(vs1.capacity() == test_defs::get<const char *>::capacity<1>());
|
|
||||||
ASSERT(vs2.capacity() == test_defs::get<const char *>::capacity<2>());
|
|
||||||
ASSERT(vs1.size() == test_defs::get<const char *>::capacity<1>());
|
|
||||||
ASSERT(vs2.size() == test_defs::get<const char *>::capacity<2>());
|
|
||||||
ASSERT_ALL_VEC_EQ(vs1, test_defs::get<const char *>::value<1>());
|
|
||||||
ASSERT_ALL_VEC_EQ(vs2, test_defs::get<const char *>::value<2>());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<TestStruct>::capacity<1>()> vo1(test_defs::get<TestStruct>::value<1>());
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<TestStruct>::capacity<2>()> vo2(test_defs::get<TestStruct>::value<2>());
|
|
||||||
|
|
||||||
ASSERT(vo1.capacity() == test_defs::get<TestStruct>::capacity<1>());
|
|
||||||
ASSERT(vo2.capacity() == test_defs::get<TestStruct>::capacity<2>());
|
|
||||||
ASSERT(vo1.size() == test_defs::get<TestStruct>::capacity<1>());
|
|
||||||
ASSERT(vo2.size() == test_defs::get<TestStruct>::capacity<2>());
|
|
||||||
ASSERT_ALL_VEC_EQ(vo1, test_defs::get<TestStruct>::value<1>());
|
|
||||||
ASSERT_ALL_VEC_EQ(vo2, test_defs::get<TestStruct>::value<2>());
|
|
||||||
|
|
||||||
return TEST_PASS();
|
|
||||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
|
||||||
("const_vector(size_type size, T &value)", []() constexpr {
|
|
||||||
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<1>()> vi1(test_defs::get<int>::size<1>(), test_defs::get<int>::value<1>());
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<2>()> vi2(test_defs::get<int>::size<2>(), test_defs::get<int>::value<2>());
|
|
||||||
|
|
||||||
ASSERT(vi1.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vi2.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vi1.size() == test_defs::get<int>::size<1>());
|
|
||||||
ASSERT(vi2.size() == test_defs::get<int>::size<2>());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi1, 0, test_defs::get<int>::size<1>(), test_defs::get<int>::value<1>());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi1, test_defs::get<int>::size<1>(), test_defs::get<int>::capacity<1>(), int());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi2, 0, test_defs::get<int>::size<2>(), test_defs::get<int>::value<2>());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi2, test_defs::get<int>::size<2>(), test_defs::get<int>::capacity<2>(), int());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector<char, test_defs::get<int>::capacity<1>()> vc1(test_defs::get<int>::size<1>(), test_defs::get<char>::value<1>());
|
|
||||||
cc::const_vector<char, test_defs::get<int>::capacity<2>()> vc2(test_defs::get<int>::size<2>(), test_defs::get<char>::value<2>());
|
|
||||||
|
|
||||||
ASSERT(vc1.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vc2.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vc1.size() == test_defs::get<int>::size<1>());
|
|
||||||
ASSERT(vc2.size() == test_defs::get<int>::size<2>());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc1, 0, test_defs::get<int>::size<1>(), test_defs::get<char>::value<1>());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc1, test_defs::get<int>::size<1>(), test_defs::get<int>::capacity<1>(), char());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc2, 0, test_defs::get<int>::size<2>(), test_defs::get<char>::value<2>());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc2, test_defs::get<int>::size<2>(), test_defs::get<int>::capacity<2>(), char());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector<const char *, test_defs::get<int>::capacity<1>()> vs1(test_defs::get<int>::size<1>(), test_defs::get<const char *>::value<1>());
|
|
||||||
cc::const_vector<const char *, test_defs::get<int>::capacity<2>()> vs2(test_defs::get<int>::size<2>(), test_defs::get<const char *>::value<2>());
|
|
||||||
|
|
||||||
ASSERT(vs1.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vs2.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vs1.size() == test_defs::get<int>::size<1>());
|
|
||||||
ASSERT(vs2.size() == test_defs::get<int>::size<2>());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vs1, 0, test_defs::get<int>::size<1>(), test_defs::get<const char *>::value<1>());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vs2, 0, test_defs::get<int>::size<2>(), test_defs::get<const char *>::value<2>());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<int>::capacity<1>()> vo1(test_defs::get<int>::size<1>(), test_defs::get<TestStruct>::value<1>());
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<int>::capacity<2>()> vo2(test_defs::get<int>::size<2>(), test_defs::get<TestStruct>::value<2>());
|
|
||||||
|
|
||||||
ASSERT(vo1.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vo2.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vo1.size() == test_defs::get<int>::size<1>());
|
|
||||||
ASSERT(vo2.size() == test_defs::get<int>::size<2>());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo1, 0, test_defs::get<int>::size<1>(), test_defs::get<TestStruct>::value<1>());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo1, test_defs::get<int>::size<1>(), test_defs::get<int>::capacity<1>(), TestStruct {});
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo2, 0, test_defs::get<int>::size<2>(), test_defs::get<TestStruct>::value<2>());
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo2, test_defs::get<int>::size<2>(), test_defs::get<int>::capacity<2>(), TestStruct {});
|
|
||||||
|
|
||||||
return TEST_PASS();
|
|
||||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
|
||||||
|
|
||||||
|
|
||||||
("const_vector(const value_type (&array)[N])", []() constexpr{
|
|
||||||
|
|
||||||
cc::const_vector vi1(test_defs::get<int>::arr<1>);
|
|
||||||
cc::const_vector vi2(test_defs::get<int>::arr<2>);
|
|
||||||
/*cc::const_vector<int, test_defs::get<int>::capacity<1>()> vi3(test_defs::get<int>::arr<1>);
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<2>()> vi4(test_defs::get<int>::arr<2>);*/
|
|
||||||
|
|
||||||
ASSERT(vi1.capacity() == test_defs::get<int>::arr_len<1>());
|
|
||||||
ASSERT(vi2.capacity() == test_defs::get<int>::arr_len<2>());
|
|
||||||
ASSERT(vi1.size() == test_defs::get<int>::arr_len<1>());
|
|
||||||
ASSERT(vi2.size() == test_defs::get<int>::arr_len<2>());
|
|
||||||
ASSERT_VEC_ARR_EQ(vi1, test_defs::get<int>::arr<1>);
|
|
||||||
ASSERT_VEC_ARR_EQ(vi2, test_defs::get<int>::arr<2>);
|
|
||||||
/*ASSERT(vi3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vi4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vi3.size() == test_defs::get<int>::arr_len<1>());
|
|
||||||
ASSERT(vi4.size() == test_defs::get<int>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vi3, 0, test_defs::get<int>::arr_len<1>(), test_defs::get<int>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi3, test_defs::get<int>::arr_len<1>(), test_defs::get<int>::capacity<1>(), int());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vi4, 0, test_defs::get<int>::arr_len<2>(), test_defs::get<int>::arr<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi4, test_defs::get<int>::arr_len<2>(), test_defs::get<int>::capacity<2>(), int());*/
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vc1(test_defs::get<char>::arr<1>);
|
|
||||||
cc::const_vector vc2(test_defs::get<char>::arr<2>);
|
|
||||||
/*cc::const_vector<char, test_defs::get<int>::capacity<1>()> vc3(test_defs::get<char>::arr<1>);
|
|
||||||
cc::const_vector<char, test_defs::get<int>::capacity<2>()> vc4(test_defs::get<char>::arr<2>);*/
|
|
||||||
|
|
||||||
ASSERT(vc1.capacity() == test_defs::get<char>::arr_len<1>());
|
|
||||||
ASSERT(vc2.capacity() == test_defs::get<char>::arr_len<2>());
|
|
||||||
ASSERT(vc1.size() == test_defs::get<char>::arr_len<1>());
|
|
||||||
ASSERT(vc2.size() == test_defs::get<char>::arr_len<2>());
|
|
||||||
ASSERT_VEC_ARR_EQ(vc1, test_defs::get<char>::arr<1>);
|
|
||||||
ASSERT_VEC_ARR_EQ(vc2, test_defs::get<char>::arr<2>);
|
|
||||||
/*ASSERT(vc3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vc4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vc3.size() == test_defs::get<char>::arr_len<1>());
|
|
||||||
ASSERT(vc4.size() == test_defs::get<char>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vc3, 0, test_defs::get<char>::arr_len<1>(), test_defs::get<char>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc3, test_defs::get<char>::arr_len<1>(), test_defs::get<int>::capacity<1>(), char());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vc4, 0, test_defs::get<char>::arr_len<2>(), test_defs::get<char>::arr<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc4, test_defs::get<char>::arr_len<2>(), test_defs::get<int>::capacity<2>(), char());*/
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vs1(test_defs::get<const char *>::arr<1>);
|
|
||||||
cc::const_vector vs2(test_defs::get<const char *>::arr<2>);
|
|
||||||
/*cc::const_vector<const char *, test_defs::get<int>::capacity<1>()> vs3(test_defs::get<const char *>::arr<1>);
|
|
||||||
cc::const_vector<const char *, test_defs::get<int>::capacity<2>()> vs4(test_defs::get<const char *>::arr<2>);*/
|
|
||||||
|
|
||||||
ASSERT(vs1.capacity() == test_defs::get<const char *>::arr_len<1>());
|
|
||||||
ASSERT(vs2.capacity() == test_defs::get<const char *>::arr_len<2>());
|
|
||||||
ASSERT(vs1.size() == test_defs::get<const char *>::arr_len<1>());
|
|
||||||
ASSERT(vs2.size() == test_defs::get<const char *>::arr_len<2>());
|
|
||||||
ASSERT_VEC_ARR_EQ(vs1, test_defs::get<const char *>::arr<1>);
|
|
||||||
ASSERT_VEC_ARR_EQ(vs2, test_defs::get<const char *>::arr<2>);
|
|
||||||
/*ASSERT(vs3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vs4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vs3.size() == test_defs::get<const char *>::arr_len<1>());
|
|
||||||
ASSERT(vs4.size() == test_defs::get<const char *>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vs3, 0, test_defs::get<const char *>::arr_len<1>(), test_defs::get<const char *>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vs4, 0, test_defs::get<const char *>::arr_len<2>(), test_defs::get<const char *>::arr<2>);*/
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vo1(test_defs::get<TestStruct>::arr<1>);
|
|
||||||
cc::const_vector vo2(test_defs::get<TestStruct>::arr<2>);
|
|
||||||
/*cc::const_vector<TestStruct, test_defs::get<int>::capacity<1>()> vo3(test_defs::get<TestStruct>::arr<1>);
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<int>::capacity<2>()> vo4(test_defs::get<TestStruct>::arr<2>);*/
|
|
||||||
|
|
||||||
ASSERT(vo1.capacity() == test_defs::get<TestStruct>::arr_len<1>());
|
|
||||||
ASSERT(vo2.capacity() == test_defs::get<TestStruct>::arr_len<2>());
|
|
||||||
ASSERT(vo1.size() == test_defs::get<TestStruct>::arr_len<1>());
|
|
||||||
ASSERT(vo2.size() == test_defs::get<TestStruct>::arr_len<2>());
|
|
||||||
ASSERT_VEC_ARR_EQ(vo1, test_defs::get<TestStruct>::arr<1>);
|
|
||||||
ASSERT_VEC_ARR_EQ(vo2, test_defs::get<TestStruct>::arr<2>);
|
|
||||||
/*ASSERT(vo3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vo4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vo3.size() == test_defs::get<TestStruct>::arr_len<1>());
|
|
||||||
ASSERT(vo4.size() == test_defs::get<TestStruct>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vo3, 0, test_defs::get<TestStruct>::arr_len<1>(), test_defs::get<TestStruct>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo3, test_defs::get<TestStruct>::arr_len<1>(), test_defs::get<int>::capacity<1>(), TestStruct {});
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vo4, 0, test_defs::get<TestStruct>::arr_len<2>(), test_defs::get<TestStruct>::arr<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo4, test_defs::get<TestStruct>::arr_len<2>(), test_defs::get<int>::capacity<2>(), TestStruct {});*/
|
|
||||||
|
|
||||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
|
||||||
|
|
||||||
("const_vector(std::initializer_list<value_type> list)", []() constexpr{
|
|
||||||
|
|
||||||
cc::const_vector vi1(test_defs::get<int>::i_list<1>);
|
|
||||||
cc::const_vector vi2(test_defs::get<int>::i_list<2>);
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<1>()> vi3(test_defs::get<int>::i_list<1>);
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<2>()> vi4(test_defs::get<int>::i_list<2>);
|
|
||||||
|
|
||||||
ASSERT(vi1.capacity() == test_defs::get<int>::arr_len<1>());
|
|
||||||
ASSERT(vi2.capacity() == test_defs::get<int>::arr_len<2>());
|
|
||||||
ASSERT(vi1.size() == test_defs::get<int>::arr_len<1>());
|
|
||||||
ASSERT(vi2.size() == test_defs::get<int>::arr_len<2>());
|
|
||||||
ASSERT_VEC_ARR_EQ(vi1, test_defs::get<int>::i_list<1>);
|
|
||||||
ASSERT_VEC_ARR_EQ(vi2, test_defs::get<int>::i_list<2>);
|
|
||||||
ASSERT(vi3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vi4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vi3.size() == test_defs::get<int>::arr_len<1>());
|
|
||||||
ASSERT(vi4.size() == test_defs::get<int>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vi3, 0, test_defs::get<int>::arr_len<1>(), test_defs::get<int>::i_list<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi3, test_defs::get<int>::arr_len<1>(), test_defs::get<int>::capacity<1>(), int());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vi4, 0, test_defs::get<int>::arr_len<2>(), test_defs::get<int>::i_list<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi4, test_defs::get<int>::arr_len<2>(), test_defs::get<int>::capacity<2>(), int());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vc1(test_defs::get<char>::i_list<1>);
|
|
||||||
cc::const_vector vc2(test_defs::get<char>::i_list<2>);
|
|
||||||
cc::const_vector<char, test_defs::get<int>::capacity<1>()> vc3(test_defs::get<char>::i_list<1>);
|
|
||||||
cc::const_vector<char, test_defs::get<int>::capacity<2>()> vc4(test_defs::get<char>::i_list<2>);
|
|
||||||
|
|
||||||
ASSERT(vc1.capacity() == test_defs::get<char>::arr_len<1>());
|
|
||||||
ASSERT(vc2.capacity() == test_defs::get<char>::arr_len<2>());
|
|
||||||
ASSERT(vc1.size() == test_defs::get<char>::arr_len<1>());
|
|
||||||
ASSERT(vc2.size() == test_defs::get<char>::arr_len<2>());
|
|
||||||
ASSERT_VEC_ARR_EQ(vc1, test_defs::get<char>::i_list<1>);
|
|
||||||
ASSERT_VEC_ARR_EQ(vc2, test_defs::get<char>::i_list<2>);
|
|
||||||
ASSERT(vc3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vc4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vc3.size() == test_defs::get<char>::arr_len<1>());
|
|
||||||
ASSERT(vc4.size() == test_defs::get<char>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vc3, 0, test_defs::get<char>::arr_len<1>(), test_defs::get<char>::i_list<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc3, test_defs::get<char>::arr_len<1>(), test_defs::get<int>::capacity<1>(), char());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vc4, 0, test_defs::get<char>::arr_len<2>(), test_defs::get<char>::i_list<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc4, test_defs::get<char>::arr_len<2>(), test_defs::get<int>::capacity<2>(), char());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vs1(test_defs::get<const char *>::i_list<1>);
|
|
||||||
cc::const_vector vs2(test_defs::get<const char *>::i_list<2>);
|
|
||||||
cc::const_vector<const char *, test_defs::get<int>::capacity<1>()> vs3(test_defs::get<const char *>::i_list<1>);
|
|
||||||
cc::const_vector<const char *, test_defs::get<int>::capacity<2>()> vs4(test_defs::get<const char *>::i_list<2>);
|
|
||||||
|
|
||||||
ASSERT(vs1.capacity() == test_defs::get<const char *>::arr_len<1>());
|
|
||||||
ASSERT(vs2.capacity() == test_defs::get<const char *>::arr_len<2>());
|
|
||||||
ASSERT(vs1.size() == test_defs::get<const char *>::arr_len<1>());
|
|
||||||
ASSERT(vs2.size() == test_defs::get<const char *>::arr_len<2>());
|
|
||||||
ASSERT_VEC_ARR_EQ(vs1, test_defs::get<const char *>::i_list<1>);
|
|
||||||
ASSERT_VEC_ARR_EQ(vs2, test_defs::get<const char *>::i_list<2>);
|
|
||||||
ASSERT(vs3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vs4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vs3.size() == test_defs::get<const char *>::arr_len<1>());
|
|
||||||
ASSERT(vs4.size() == test_defs::get<const char *>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vs3, 0, test_defs::get<const char *>::arr_len<1>(), test_defs::get<const char *>::i_list<1>);
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vs4, 0, test_defs::get<const char *>::arr_len<2>(), test_defs::get<const char *>::i_list<2>);
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vo1(test_defs::get<TestStruct>::i_list<1>);
|
|
||||||
cc::const_vector vo2(test_defs::get<TestStruct>::i_list<2>);
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<int>::capacity<1>()> vo3(test_defs::get<TestStruct>::i_list<1>);
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<int>::capacity<2>()> vo4(test_defs::get<TestStruct>::i_list<2>);
|
|
||||||
|
|
||||||
ASSERT(vo1.capacity() == test_defs::get<TestStruct>::arr_len<1>());
|
|
||||||
ASSERT(vo2.capacity() == test_defs::get<TestStruct>::arr_len<2>());
|
|
||||||
ASSERT(vo1.size() == test_defs::get<TestStruct>::arr_len<1>());
|
|
||||||
ASSERT(vo2.size() == test_defs::get<TestStruct>::arr_len<2>());
|
|
||||||
ASSERT_VEC_ARR_EQ(vo1, test_defs::get<TestStruct>::i_list<1>);
|
|
||||||
ASSERT_VEC_ARR_EQ(vo2, test_defs::get<TestStruct>::i_list<2>);
|
|
||||||
ASSERT(vo3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vo4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vo3.size() == test_defs::get<TestStruct>::arr_len<1>());
|
|
||||||
ASSERT(vo4.size() == test_defs::get<TestStruct>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vo3, 0, test_defs::get<TestStruct>::arr_len<1>(), test_defs::get<TestStruct>::i_list<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo3, test_defs::get<TestStruct>::arr_len<1>(), test_defs::get<int>::capacity<1>(), TestStruct {});
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vo4, 0, test_defs::get<TestStruct>::arr_len<2>(), test_defs::get<TestStruct>::i_list<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo4, test_defs::get<TestStruct>::arr_len<2>(), test_defs::get<int>::capacity<2>(), TestStruct {});
|
|
||||||
|
|
||||||
return TEST_PASS();
|
|
||||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
|
||||||
|
|
||||||
("const_vector(InputIt first, InputIt last)", []() constexpr{
|
|
||||||
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<1>()> vi1(std::begin(test_defs::get<int>::arr<1>), std::end(test_defs::get<int>::arr<1>));
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<2>()> vi2(std::begin(test_defs::get<int>::arr<2>), std::end(test_defs::get<int>::arr<2>));
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<1>()> vi3(std::begin(test_defs::get<int>::arr<1>), std::end(test_defs::get<int>::arr<1>));
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<2>()> vi4(std::begin(test_defs::get<int>::arr<2>), std::end(test_defs::get<int>::arr<2>));
|
|
||||||
|
|
||||||
ASSERT(vi1.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vi2.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vi1.size() == test_defs::get<int>::arr_len<1>());
|
|
||||||
ASSERT(vi2.size() == test_defs::get<int>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vi1, 0, test_defs::get<int>::arr_len<1>(), test_defs::get<int>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi1, test_defs::get<int>::arr_len<1>(), test_defs::get<int>::capacity<1>(), int());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vi2, 0, test_defs::get<int>::arr_len<2>(), test_defs::get<int>::arr<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi2, test_defs::get<int>::arr_len<2>(), test_defs::get<int>::capacity<2>(), int());
|
|
||||||
ASSERT(vi3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vi4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vi3.size() == test_defs::get<int>::arr_len<1>());
|
|
||||||
ASSERT(vi4.size() == test_defs::get<int>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vi3, 0, test_defs::get<int>::arr_len<1>(), test_defs::get<int>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi3, test_defs::get<int>::arr_len<1>(), test_defs::get<int>::capacity<1>(), int());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vi4, 0, test_defs::get<int>::arr_len<2>(), test_defs::get<int>::arr<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi4, test_defs::get<int>::arr_len<2>(), test_defs::get<int>::capacity<2>(), int());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector<char, test_defs::get<int>::capacity<1>()> vc1(std::begin(test_defs::get<char>::arr<1>), std::end(test_defs::get<char>::arr<1>));
|
|
||||||
cc::const_vector<char, test_defs::get<int>::capacity<2>()> vc2(std::begin(test_defs::get<char>::arr<2>), std::end(test_defs::get<char>::arr<2>));
|
|
||||||
cc::const_vector<char, test_defs::get<int>::capacity<1>()> vc3(std::begin(test_defs::get<char>::arr<1>), std::end(test_defs::get<char>::arr<1>));
|
|
||||||
cc::const_vector<char, test_defs::get<int>::capacity<2>()> vc4(std::begin(test_defs::get<char>::arr<2>), std::end(test_defs::get<char>::arr<2>));
|
|
||||||
|
|
||||||
ASSERT(vc1.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vc2.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vc1.size() == test_defs::get<char>::arr_len<1>());
|
|
||||||
ASSERT(vc2.size() == test_defs::get<char>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vc1, 0, test_defs::get<char>::arr_len<1>(), test_defs::get<char>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc1, test_defs::get<char>::arr_len<1>(), test_defs::get<int>::capacity<1>(), char());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vc2, 0, test_defs::get<char>::arr_len<2>(), test_defs::get<char>::arr<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc2, test_defs::get<char>::arr_len<2>(), test_defs::get<int>::capacity<2>(), char());
|
|
||||||
ASSERT(vc3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vc4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vc3.size() == test_defs::get<char>::arr_len<1>());
|
|
||||||
ASSERT(vc4.size() == test_defs::get<char>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vc3, 0, test_defs::get<char>::arr_len<1>(), test_defs::get<char>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc3, test_defs::get<char>::arr_len<1>(), test_defs::get<int>::capacity<1>(), char());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vc4, 0, test_defs::get<char>::arr_len<2>(), test_defs::get<char>::arr<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc4, test_defs::get<char>::arr_len<2>(), test_defs::get<int>::capacity<2>(), char());
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector<const char *, test_defs::get<int>::capacity<1>()> vs1(std::begin(test_defs::get<const char *>::arr<1>), std::end(test_defs::get<const char *>::arr<1>));
|
|
||||||
cc::const_vector<const char *, test_defs::get<int>::capacity<2>()> vs2(std::begin(test_defs::get<const char *>::arr<2>), std::end(test_defs::get<const char *>::arr<2>));
|
|
||||||
cc::const_vector<const char *, test_defs::get<int>::capacity<1>()> vs3(std::begin(test_defs::get<const char *>::arr<1>), std::end(test_defs::get<const char *>::arr<1>));
|
|
||||||
cc::const_vector<const char *, test_defs::get<int>::capacity<2>()> vs4(std::begin(test_defs::get<const char *>::arr<2>), std::end(test_defs::get<const char *>::arr<2>));
|
|
||||||
|
|
||||||
ASSERT(vs1.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vs2.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vs1.size() == test_defs::get<const char *>::arr_len<1>());
|
|
||||||
ASSERT(vs2.size() == test_defs::get<const char *>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vs1, 0, test_defs::get<const char *>::arr_len<1>(), test_defs::get<const char *>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vs2, 0, test_defs::get<const char *>::arr_len<2>(), test_defs::get<const char *>::arr<2>);
|
|
||||||
ASSERT(vs3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vs4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vs3.size() == test_defs::get<const char *>::arr_len<1>());
|
|
||||||
ASSERT(vs4.size() == test_defs::get<const char *>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vs3, 0, test_defs::get<const char *>::arr_len<1>(), test_defs::get<const char *>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vs4, 0, test_defs::get<const char *>::arr_len<2>(), test_defs::get<const char *>::arr<2>);
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<int>::capacity<1>()> vo1(std::begin(test_defs::get<TestStruct>::arr<1>), std::end(test_defs::get<TestStruct>::arr<1>));
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<int>::capacity<2>()> vo2(std::begin(test_defs::get<TestStruct>::arr<2>), std::end(test_defs::get<TestStruct>::arr<2>));
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<int>::capacity<1>()> vo3(std::begin(test_defs::get<TestStruct>::arr<1>), std::end(test_defs::get<TestStruct>::arr<1>));
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<int>::capacity<2>()> vo4(std::begin(test_defs::get<TestStruct>::arr<2>), std::end(test_defs::get<TestStruct>::arr<2>));
|
|
||||||
|
|
||||||
ASSERT(vo1.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vo2.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vo1.size() == test_defs::get<TestStruct>::arr_len<1>());
|
|
||||||
ASSERT(vo2.size() == test_defs::get<TestStruct>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vo1, 0, test_defs::get<TestStruct>::arr_len<1>(), test_defs::get<TestStruct>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo1, test_defs::get<TestStruct>::arr_len<1>(), test_defs::get<int>::capacity<1>(), TestStruct {});
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vo2, 0, test_defs::get<TestStruct>::arr_len<2>(), test_defs::get<TestStruct>::arr<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo2, test_defs::get<TestStruct>::arr_len<2>(), test_defs::get<int>::capacity<2>(), TestStruct {});
|
|
||||||
ASSERT(vo3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vo4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vo3.size() == test_defs::get<TestStruct>::arr_len<1>());
|
|
||||||
ASSERT(vo4.size() == test_defs::get<TestStruct>::arr_len<2>());
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vo3, 0, test_defs::get<TestStruct>::arr_len<1>(), test_defs::get<TestStruct>::arr<1>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo3, test_defs::get<TestStruct>::arr_len<1>(), test_defs::get<int>::capacity<1>(), TestStruct {});
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vo4, 0, test_defs::get<TestStruct>::arr_len<2>(), test_defs::get<TestStruct>::arr<2>);
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo4, test_defs::get<TestStruct>::arr_len<2>(), test_defs::get<int>::capacity<2>(), TestStruct {});
|
|
||||||
|
|
||||||
return TEST_PASS();
|
|
||||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
|
||||||
|
|
||||||
("const_vector(const const_vector& other)", []() constexpr{
|
|
||||||
|
|
||||||
cc::const_vector vi1(test_defs::get<int>::arr<1>);
|
|
||||||
cc::const_vector vi2(test_defs::get<int>::arr<2>);
|
|
||||||
cc::const_vector vi1c(vi1);
|
|
||||||
cc::const_vector vi2c(vi2);
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<1>()> vi3(vi1);
|
|
||||||
cc::const_vector<int, test_defs::get<int>::capacity<2>()> vi4(vi2);
|
|
||||||
|
|
||||||
ASSERT(vi1c.capacity() == vi1.capacity());
|
|
||||||
ASSERT(vi2c.capacity() == vi2.capacity());
|
|
||||||
ASSERT(vi1c.size() == vi1.size());
|
|
||||||
ASSERT(vi2c.size() == vi2.size());
|
|
||||||
ASSERT_VEC_EQ(vi1c, vi1);
|
|
||||||
ASSERT_VEC_EQ(vi2c, vi2);
|
|
||||||
ASSERT(vi3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vi4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vi3.size() == vi1.size());
|
|
||||||
ASSERT(vi4.size() == vi2.size());
|
|
||||||
ASSERT_VEC_EQ(vi3, vi1);
|
|
||||||
ASSERT_VEC_EQ(vi4, vi2);
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vc1(test_defs::get<char>::arr<1>);
|
|
||||||
cc::const_vector vc2(test_defs::get<char>::arr<2>);
|
|
||||||
cc::const_vector vc1c(vc1);
|
|
||||||
cc::const_vector vc2c(vc2);
|
|
||||||
cc::const_vector<char, test_defs::get<int>::capacity<1>()> vc3(vc1);
|
|
||||||
cc::const_vector<char, test_defs::get<int>::capacity<2>()> vc4(vc2);
|
|
||||||
|
|
||||||
ASSERT(vc1c.capacity() == vc1.capacity());
|
|
||||||
ASSERT(vc2c.capacity() == vc2.capacity());
|
|
||||||
ASSERT(vc1c.size() == vc1.size());
|
|
||||||
ASSERT(vc2c.size() == vc2.size());
|
|
||||||
ASSERT_VEC_EQ(vc1c, vc1);
|
|
||||||
ASSERT_VEC_EQ(vc2c, vc2);
|
|
||||||
ASSERT(vc3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vc4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vc3.size() == vc1.size());
|
|
||||||
ASSERT(vc4.size() == vc2.size());
|
|
||||||
ASSERT_VEC_EQ(vc3, vc1);
|
|
||||||
ASSERT_VEC_EQ(vc4, vc2);
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vs1(test_defs::get<const char *>::arr<1>);
|
|
||||||
cc::const_vector vs2(test_defs::get<const char *>::arr<2>);
|
|
||||||
cc::const_vector vs1c(vs1);
|
|
||||||
cc::const_vector vs2c(vs2);
|
|
||||||
cc::const_vector<const char *, test_defs::get<int>::capacity<1>()> vs3(vs1);
|
|
||||||
cc::const_vector<const char *, test_defs::get<int>::capacity<2>()> vs4(vs2);
|
|
||||||
|
|
||||||
ASSERT(vs1c.capacity() == vs1.capacity());
|
|
||||||
ASSERT(vs2c.capacity() == vs2.capacity());
|
|
||||||
ASSERT(vs1c.size() == vs1.size());
|
|
||||||
ASSERT(vs2c.size() == vs2.size());
|
|
||||||
ASSERT_VEC_EQ(vs1c, vs1);
|
|
||||||
ASSERT_VEC_EQ(vs2c, vs2);
|
|
||||||
ASSERT(vs3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vs4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vs3.size() == vs1.size());
|
|
||||||
ASSERT(vs4.size() == vs2.size());
|
|
||||||
ASSERT_VEC_EQ(vs3, vs1);
|
|
||||||
ASSERT_VEC_EQ(vs4, vs2);
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vo1(test_defs::get<TestStruct>::arr<1>);
|
|
||||||
cc::const_vector vo2(test_defs::get<TestStruct>::arr<2>);
|
|
||||||
cc::const_vector vo1c(vo1);
|
|
||||||
cc::const_vector vo2c(vo2);
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<TestStruct>::capacity<1>()> vo3(vo1);
|
|
||||||
cc::const_vector<TestStruct, test_defs::get<TestStruct>::capacity<2>()> vo4(vo2);
|
|
||||||
|
|
||||||
ASSERT(vo1c.capacity() == vo1.capacity());
|
|
||||||
ASSERT(vo2c.capacity() == vo2.capacity());
|
|
||||||
ASSERT(vo1c.size() == vo1.size());
|
|
||||||
ASSERT(vo2c.size() == vo2.size());
|
|
||||||
ASSERT_VEC_EQ(vo1c, vo1);
|
|
||||||
ASSERT_VEC_EQ(vo2c, vo2);
|
|
||||||
ASSERT(vo3.capacity() == test_defs::get<int>::capacity<1>());
|
|
||||||
ASSERT(vo4.capacity() == test_defs::get<int>::capacity<2>());
|
|
||||||
ASSERT(vo3.size() == vo1.size());
|
|
||||||
ASSERT(vo4.size() == vo2.size());
|
|
||||||
ASSERT_VEC_EQ(vo3, vo1);
|
|
||||||
ASSERT_VEC_EQ(vo4, vo2);
|
|
||||||
|
|
||||||
return TEST_PASS();
|
|
||||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
|
||||||
|
|
||||||
("const_vector(const_vector&& other)", []() constexpr {
|
|
||||||
|
|
||||||
cc::const_vector vi1(test_defs::get<int>::arr<1>);
|
|
||||||
cc::const_vector vi2(test_defs::get<int>::arr<2>);
|
|
||||||
cc::const_vector vi1c(vi1);
|
|
||||||
cc::const_vector vi2c(vi2);
|
|
||||||
cc::const_vector vi3(const_cast<std::remove_const_t<decltype(vi1)>&&>(vi1));
|
|
||||||
cc::const_vector vi4(const_cast<std::remove_const_t<decltype(vi2)>&&>(vi2));
|
|
||||||
|
|
||||||
ASSERT(vi3.capacity() == vi1c.capacity());
|
|
||||||
ASSERT(vi4.capacity() == vi2c.capacity());
|
|
||||||
ASSERT(vi3.size() == vi1c.size());
|
|
||||||
ASSERT(vi4.size() == vi2c.size());
|
|
||||||
ASSERT_VEC_EQ(vi3, vi1c);
|
|
||||||
ASSERT_VEC_EQ(vi4, vi2c);
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vc1(test_defs::get<char>::arr<1>);
|
|
||||||
cc::const_vector vc2(test_defs::get<char>::arr<2>);
|
|
||||||
cc::const_vector vc1c(vc1);
|
|
||||||
cc::const_vector vc2c(vc2);
|
|
||||||
cc::const_vector vc3(const_cast<std::remove_const_t<decltype(vc1)>&&>(vc1));
|
|
||||||
cc::const_vector vc4(const_cast<std::remove_const_t<decltype(vc2)>&&>(vc2));
|
|
||||||
|
|
||||||
ASSERT(vi3.capacity() == vi1c.capacity());
|
|
||||||
ASSERT(vi4.capacity() == vi2c.capacity());
|
|
||||||
ASSERT(vi3.size() == vi1c.size());
|
|
||||||
ASSERT(vi4.size() == vi2c.size());
|
|
||||||
ASSERT_VEC_EQ(vi3, vi1c);
|
|
||||||
ASSERT_VEC_EQ(vi4, vi2c);
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vs1(test_defs::get<const char *>::arr<1>);
|
|
||||||
cc::const_vector vs2(test_defs::get<const char *>::arr<2>);
|
|
||||||
cc::const_vector vs1c(vs1);
|
|
||||||
cc::const_vector vs2c(vs2);
|
|
||||||
cc::const_vector vs3(const_cast<std::remove_const_t<decltype(vs1)>&&>(vs1));
|
|
||||||
cc::const_vector vs4(const_cast<std::remove_const_t<decltype(vs2)>&&>(vs2));
|
|
||||||
|
|
||||||
ASSERT(vs3.capacity() == vs1c.capacity());
|
|
||||||
ASSERT(vs4.capacity() == vs2c.capacity());
|
|
||||||
ASSERT(vs3.size() == vs1c.size());
|
|
||||||
ASSERT(vs4.size() == vs2c.size());
|
|
||||||
ASSERT_VEC_EQ(vs3, vs1c);
|
|
||||||
ASSERT_VEC_EQ(vs4, vs2c);
|
|
||||||
|
|
||||||
|
|
||||||
cc::const_vector vo1(test_defs::get<TestStruct>::arr<1>);
|
|
||||||
cc::const_vector vo2(test_defs::get<TestStruct>::arr<2>);
|
|
||||||
cc::const_vector vo1c(vo1);
|
|
||||||
cc::const_vector vo2c(vo2);
|
|
||||||
cc::const_vector vo3(const_cast<std::remove_const_t<decltype(vo1)>&&>(vo1));
|
|
||||||
cc::const_vector vo4(const_cast<std::remove_const_t<decltype(vo2)>&&>(vo2));
|
|
||||||
|
|
||||||
ASSERT(vo3.capacity() == vo1c.capacity());
|
|
||||||
ASSERT(vo4.capacity() == vo2c.capacity());
|
|
||||||
ASSERT(vo3.size() == vo1c.size());
|
|
||||||
ASSERT(vo4.size() == vo2c.size());
|
|
||||||
ASSERT_VEC_EQ(vo3, vo1c);
|
|
||||||
ASSERT_VEC_EQ(vo4, vo2c);
|
|
||||||
|
|
||||||
return TEST_PASS();
|
|
||||||
}, EvalFlag::RUNTIME_CONSTEVAL)
|
|
||||||
|
|
||||||
/*("const_vector(const_vector&& other)", []() {
|
|
||||||
|
|
||||||
return TEST_PASS();
|
|
||||||
}, EvalFlag::RUNTIME_CONSTEVAL)*/
|
|
||||||
;
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
return tests.run();
|
return tests.run();
|
||||||
|
|
|
||||||
|
|
@ -4,19 +4,11 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
|
||||||
#define C_ARR_LEN(arr) (sizeof(arr)/sizeof(arr[0]))
|
#include "test/common_helper/test_util.h"
|
||||||
|
|
||||||
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 {
|
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 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_VEC1_CAPACITY 5
|
||||||
|
|
@ -25,8 +17,13 @@ struct test_defs {
|
||||||
#define TEST_VEC1_SIZE 3
|
#define TEST_VEC1_SIZE 3
|
||||||
#define TEST_VEC2_SIZE 7
|
#define TEST_VEC2_SIZE 7
|
||||||
|
|
||||||
/*#define { 1, 2, 3, 4 } { 1, 2, 3, 4 }
|
#define VI_TEST_VAL 5
|
||||||
#define { 5, 6, 7, 8, 9, 10, 11, 12 } { 5, 6, 7, 8, 9, 10, 11, 12 }
|
#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_ARR1 { 'a', 'B', 'c', 'D' }
|
||||||
#define VC_TEST_ARR2 { 'e', 'F', 'g', 'H', 'i', 'J', '\n', '\0' }
|
#define VC_TEST_ARR2 { 'e', 'F', 'g', 'H', 'i', 'J', '\n', '\0' }
|
||||||
|
|
@ -45,100 +42,99 @@ struct test_defs {
|
||||||
GEN_TEST_STRUCT_ARR(2, 4), \
|
GEN_TEST_STRUCT_ARR(2, 4), \
|
||||||
GEN_TEST_STRUCT_ARR(2, 5), \
|
GEN_TEST_STRUCT_ARR(2, 5), \
|
||||||
GEN_TEST_STRUCT_ARR(2, 6), \
|
GEN_TEST_STRUCT_ARR(2, 6), \
|
||||||
GEN_TEST_STRUCT_ARR(2, 7) }*/
|
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>
|
template<typename T>
|
||||||
struct get {
|
struct get {
|
||||||
template<std::size_t nr>
|
template<std::size_t nr>
|
||||||
static constexpr T arr[] = {};
|
static consteval auto& i_list();
|
||||||
|
|
||||||
template<std::size_t nr>
|
template<std::size_t nr>
|
||||||
static constexpr std::initializer_list<T> i_list = {};
|
static consteval auto & arr();
|
||||||
|
|
||||||
template<std::size_t nr>
|
template<std::size_t nr>
|
||||||
static consteval std::size_t arr_len();
|
static consteval std::size_t arr_len();
|
||||||
|
|
||||||
template<std::size_t nr>
|
template<std::size_t nr>
|
||||||
static consteval std::size_t capacity();
|
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<typename T>
|
||||||
template<std::size_t nr>
|
template<std::size_t nr>
|
||||||
consteval std::size_t test_defs::get<T>::arr_len() { return C_ARR_LEN(arr<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<typename T>
|
||||||
template<std::size_t nr>
|
template<std::size_t nr>
|
||||||
consteval std::size_t test_defs::get<T>::capacity() { return 0; }
|
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 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<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<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<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<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<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<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<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<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<int>::capacity<2>() { return TEST_VEC2_CAPACITY; }
|
||||||
|
|
@ -149,22 +145,5 @@ template<> template<> consteval std::size_t test_defs::get<const char *>::capaci
|
||||||
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<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<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_
|
#endif //UDIFF_TEST_ARGS_H_
|
||||||
|
|
|
||||||
|
|
@ -1048,100 +1048,7 @@ class test_const_vector : public test_defs {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static consteval bool test_data_access() {
|
|
||||||
|
|
||||||
#pragma message("Testing data access")
|
|
||||||
|
|
||||||
constexpr cc::const_vector vi1(VI_TEST_ARR1);
|
|
||||||
constexpr cc::const_vector vi2(VI_TEST_ARR2);
|
|
||||||
constexpr cc::const_vector<int, TEST_VEC1_CAPACITY> vi3(VI_TEST_ARR1);
|
|
||||||
constexpr cc::const_vector<int, TEST_VEC2_CAPACITY> vi4(VI_TEST_ARR2);
|
|
||||||
|
|
||||||
for (int i = 0; i < vi1.size(); i++) {
|
|
||||||
ASSERT(vi1.at(i) == C_VI_TEST_ARR1[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(vi1.at(0) == C_VI_TEST_ARR1[0])
|
|
||||||
ASSERT(vi2.at(0) == C_VI_TEST_ARR2[0])
|
|
||||||
ASSERT(vi1.at(1) == C_VI_TEST_ARR1[1])
|
|
||||||
ASSERT(vi2.at(1) == C_VI_TEST_ARR2[1])
|
|
||||||
ASSERT_VEC_ARR_EQ(vi1, C_VI_TEST_ARR1)
|
|
||||||
ASSERT_VEC_ARR_EQ(vi2, C_VI_TEST_ARR2)
|
|
||||||
ASSERT(vi3._len == TEST_VEC1_CAPACITY)
|
|
||||||
ASSERT(vi4._len == TEST_VEC2_CAPACITY)
|
|
||||||
ASSERT(vi3._size == VI_TEST_ARR1_LEN)
|
|
||||||
ASSERT(vi4._size == VI_TEST_ARR2_LEN)
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vi3, 0, VI_TEST_ARR1_LEN, C_VI_TEST_ARR1)
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi3, VI_TEST_ARR1_LEN, TEST_VEC1_CAPACITY, int())
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vi4, 0, VI_TEST_ARR2_LEN, C_VI_TEST_ARR2)
|
|
||||||
ASSERT_RANGE_VEC_EQ(vi4, VI_TEST_ARR2_LEN, TEST_VEC2_CAPACITY, int())
|
|
||||||
|
|
||||||
|
|
||||||
constexpr cc::const_vector vc1(VC_TEST_ARR1);
|
|
||||||
constexpr cc::const_vector vc2(VC_TEST_ARR2);
|
|
||||||
constexpr cc::const_vector<char, TEST_VEC1_CAPACITY> vc3(VC_TEST_ARR1);
|
|
||||||
constexpr cc::const_vector<char, TEST_VEC2_CAPACITY> vc4(VC_TEST_ARR2);
|
|
||||||
|
|
||||||
ASSERT(vc1._len == VC_TEST_ARR1_LEN)
|
|
||||||
ASSERT(vc2._len == VC_TEST_ARR2_LEN)
|
|
||||||
ASSERT(vc1._size == VC_TEST_ARR1_LEN)
|
|
||||||
ASSERT(vc2._size == VC_TEST_ARR2_LEN)
|
|
||||||
ASSERT_VEC_ARR_EQ(vc1, C_VC_TEST_ARR1)
|
|
||||||
ASSERT_VEC_ARR_EQ(vc2, C_VC_TEST_ARR2)
|
|
||||||
ASSERT(vc3._len == TEST_VEC1_CAPACITY)
|
|
||||||
ASSERT(vc4._len == TEST_VEC2_CAPACITY)
|
|
||||||
ASSERT(vc3._size == VC_TEST_ARR1_LEN)
|
|
||||||
ASSERT(vc4._size == VC_TEST_ARR2_LEN)
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vc3, 0, VC_TEST_ARR1_LEN, C_VC_TEST_ARR1)
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc3, VC_TEST_ARR1_LEN, TEST_VEC1_CAPACITY, char())
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vc4, 0, VC_TEST_ARR2_LEN, C_VC_TEST_ARR2)
|
|
||||||
ASSERT_RANGE_VEC_EQ(vc4, VC_TEST_ARR2_LEN, TEST_VEC2_CAPACITY, char())
|
|
||||||
|
|
||||||
|
|
||||||
constexpr cc::const_vector vs1(VS_TEST_ARR1);
|
|
||||||
constexpr cc::const_vector vs2(VS_TEST_ARR2);
|
|
||||||
constexpr cc::const_vector<const char *, TEST_VEC1_CAPACITY> vs3(VS_TEST_ARR1);
|
|
||||||
constexpr cc::const_vector<const char *, TEST_VEC2_CAPACITY> vs4(VS_TEST_ARR2);
|
|
||||||
|
|
||||||
ASSERT(vs1._len == VS_TEST_ARR1_LEN)
|
|
||||||
ASSERT(vs2._len == VS_TEST_ARR2_LEN)
|
|
||||||
ASSERT(vs1._size == VS_TEST_ARR1_LEN)
|
|
||||||
ASSERT(vs2._size == VS_TEST_ARR2_LEN)
|
|
||||||
ASSERT_VEC_ARR_EQ(vs1, C_VS_TEST_ARR1)
|
|
||||||
ASSERT_VEC_ARR_EQ(vs2, C_VS_TEST_ARR2)
|
|
||||||
ASSERT(vs3._len == TEST_VEC1_CAPACITY)
|
|
||||||
ASSERT(vs4._len == TEST_VEC2_CAPACITY)
|
|
||||||
ASSERT(vs3._size == VS_TEST_ARR1_LEN)
|
|
||||||
ASSERT(vs4._size == VS_TEST_ARR2_LEN)
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vs3, 0, VS_TEST_ARR1_LEN, C_VS_TEST_ARR1)
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vs4, 0, VS_TEST_ARR2_LEN, C_VS_TEST_ARR2)
|
|
||||||
|
|
||||||
|
|
||||||
constexpr cc::const_vector vo1(VO_TEST_ARR1);
|
|
||||||
constexpr cc::const_vector vo2(VO_TEST_ARR2);
|
|
||||||
constexpr cc::const_vector<TestStruct, TEST_VEC1_CAPACITY> vo3(VO_TEST_ARR1);
|
|
||||||
constexpr cc::const_vector<TestStruct, TEST_VEC2_CAPACITY> vo4(VO_TEST_ARR2);
|
|
||||||
|
|
||||||
ASSERT(vo1._len == VO_TEST_ARR1_LEN)
|
|
||||||
ASSERT(vo2._len == VO_TEST_ARR2_LEN)
|
|
||||||
ASSERT(vo1._size == VO_TEST_ARR1_LEN)
|
|
||||||
ASSERT(vo2._size == VO_TEST_ARR2_LEN)
|
|
||||||
ASSERT_VEC_ARR_EQ(vo1, C_VO_TEST_ARR1)
|
|
||||||
ASSERT_VEC_ARR_EQ(vo2, C_VO_TEST_ARR2)
|
|
||||||
ASSERT(vo3._len == TEST_VEC1_CAPACITY)
|
|
||||||
ASSERT(vo4._len == TEST_VEC2_CAPACITY)
|
|
||||||
ASSERT(vo3._size == VO_TEST_ARR1_LEN)
|
|
||||||
ASSERT(vo4._size == VO_TEST_ARR2_LEN)
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vo3, 0, VO_TEST_ARR1_LEN, C_VO_TEST_ARR1)
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo3, VO_TEST_ARR1_LEN, TEST_VEC1_CAPACITY, TestStruct {})
|
|
||||||
ASSERT_RANGE_VEC_ARR_EQ(vo4, 0, VO_TEST_ARR2_LEN, C_VO_TEST_ARR2)
|
|
||||||
ASSERT_RANGE_VEC_EQ(vo4, VO_TEST_ARR2_LEN, TEST_VEC2_CAPACITY, TestStruct {})
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int, char *[])
|
int main(int, char *[])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue