added test for assign()
This commit is contained in:
parent
5441e8a03c
commit
a2d571083c
|
|
@ -943,6 +943,109 @@ class test_const_vector : public test_defs {
|
|||
ASSERT_VEC_ARR_EQ(obj_res.v2i, C_VO_TEST_ARR2)
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static consteval bool test_assign() {
|
||||
|
||||
#pragma message("Testing assign()")
|
||||
|
||||
constexpr auto applicator = [] <typename T> () consteval {
|
||||
constexpr auto &arr1 = test_defs::get<T>::template arr<1>();
|
||||
constexpr auto &arr2 = test_defs::get<T>::template arr<2>();
|
||||
constexpr auto arr1_len = test_defs::get<T>::template arr_len<1>();
|
||||
constexpr auto arr2_len = test_defs::get<T>::template arr_len<2>();
|
||||
constexpr auto arr1_cap = test_defs::get<T>::template capacity<1>();
|
||||
constexpr auto arr2_cap = test_defs::get<T>::template capacity<2>();
|
||||
cc::const_vector v1o(arr1);
|
||||
cc::const_vector v2o(arr2);
|
||||
struct {
|
||||
cc::const_vector<T, arr1_cap> v1v;
|
||||
cc::const_vector<T, arr2_cap> v2v;
|
||||
cc::const_vector<T, 1> vvo;
|
||||
cc::const_vector<T, arr1_cap> v1it;
|
||||
cc::const_vector<T, arr2_cap> v2it;
|
||||
cc::const_vector<T, arr1_cap> v1i;
|
||||
cc::const_vector<T, arr2_cap> v2i;
|
||||
} ret;
|
||||
|
||||
ret.v1v.assign(arr1_len, arr1[0]);
|
||||
ret.v2v.assign(arr2_len, arr2[0]);
|
||||
ret.vvo.assign(arr1_len, arr1[0]);
|
||||
ret.v1it.assign(std::begin(arr1), std::end(arr1));
|
||||
ret.v2it.assign(std::begin(arr2), std::end(arr2));
|
||||
ret.v1i.assign(test_defs::get<T>::template i_list<1>());
|
||||
ret.v2i.assign(test_defs::get<T>::template i_list<2>());
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
constexpr auto int_res = applicator.operator()<int>();
|
||||
constexpr auto char_res = applicator.operator()<char>();
|
||||
constexpr auto string_res = applicator.operator()<const char *>();
|
||||
constexpr auto obj_res = applicator.operator()<TestStruct>();
|
||||
|
||||
ASSERT(int_res.v1v._size == VI_TEST_ARR1_LEN)
|
||||
ASSERT(int_res.v2v._size == VI_TEST_ARR2_LEN)
|
||||
ASSERT_ALL_EQ(int_res.v1v.begin(), int_res.v1v.end(), C_VI_TEST_ARR1[0])
|
||||
ASSERT_ALL_EQ(int_res.v2v.begin(), int_res.v2v.end(), C_VI_TEST_ARR2[0])
|
||||
ASSERT(int_res.vvo._size == int_res.vvo._len)
|
||||
ASSERT_ALL_EQ(int_res.vvo.begin(), int_res.vvo.end(), C_VI_TEST_ARR1[0])
|
||||
ASSERT(int_res.v1it._size == VI_TEST_ARR1_LEN)
|
||||
ASSERT(int_res.v2it._size == VI_TEST_ARR2_LEN)
|
||||
ASSERT_ARR_EQ(int_res.v1it.begin(), int_res.v1it.end(), C_VI_TEST_ARR1)
|
||||
ASSERT_ARR_EQ(int_res.v2it.begin(), int_res.v2it.end(), C_VI_TEST_ARR2)
|
||||
ASSERT(int_res.v1i._size == VI_TEST_ARR1_LEN)
|
||||
ASSERT(int_res.v2i._size == VI_TEST_ARR2_LEN)
|
||||
ASSERT_ARR_EQ(int_res.v1i.begin(), int_res.v1i.end(), C_VI_TEST_ARR1)
|
||||
ASSERT_ARR_EQ(int_res.v2i.begin(), int_res.v2i.end(), C_VI_TEST_ARR2)
|
||||
|
||||
ASSERT(char_res.v1v._size == VC_TEST_ARR1_LEN)
|
||||
ASSERT(char_res.v2v._size == VC_TEST_ARR2_LEN)
|
||||
ASSERT_ALL_EQ(char_res.v1v.begin(), char_res.v1v.end(), C_VC_TEST_ARR1[0])
|
||||
ASSERT_ALL_EQ(char_res.v2v.begin(), char_res.v2v.end(), C_VC_TEST_ARR2[0])
|
||||
ASSERT(char_res.vvo._size == char_res.vvo._len)
|
||||
ASSERT_ALL_EQ(char_res.vvo.begin(), char_res.vvo.end(), C_VC_TEST_ARR1[0])
|
||||
ASSERT(char_res.v1it._size == VC_TEST_ARR1_LEN)
|
||||
ASSERT(char_res.v2it._size == VC_TEST_ARR2_LEN)
|
||||
ASSERT_ARR_EQ(char_res.v1it.begin(), char_res.v1it.end(), C_VC_TEST_ARR1)
|
||||
ASSERT_ARR_EQ(char_res.v2it.begin(), char_res.v2it.end(), C_VC_TEST_ARR2)
|
||||
ASSERT(char_res.v1i._size == VC_TEST_ARR1_LEN)
|
||||
ASSERT(char_res.v2i._size == VC_TEST_ARR2_LEN)
|
||||
ASSERT_ARR_EQ(char_res.v1i.begin(), char_res.v1i.end(), C_VC_TEST_ARR1)
|
||||
ASSERT_ARR_EQ(char_res.v2i.begin(), char_res.v2i.end(), C_VC_TEST_ARR2)
|
||||
|
||||
ASSERT(string_res.v1v._size == VS_TEST_ARR1_LEN)
|
||||
ASSERT(string_res.v2v._size == VS_TEST_ARR2_LEN)
|
||||
ASSERT_ALL_EQ(string_res.v1v.begin(), string_res.v1v.end(), C_VS_TEST_ARR1[0])
|
||||
ASSERT_ALL_EQ(string_res.v2v.begin(), string_res.v2v.end(), C_VS_TEST_ARR2[0])
|
||||
ASSERT(string_res.vvo._size == string_res.vvo._len)
|
||||
ASSERT_ALL_EQ(string_res.vvo.begin(), string_res.vvo.end(), C_VS_TEST_ARR1[0])
|
||||
ASSERT(string_res.v1it._size == VS_TEST_ARR1_LEN)
|
||||
ASSERT(string_res.v2it._size == VS_TEST_ARR2_LEN)
|
||||
ASSERT_ARR_EQ(string_res.v1it.begin(), string_res.v1it.end(), C_VS_TEST_ARR1)
|
||||
ASSERT_ARR_EQ(string_res.v2it.begin(), string_res.v2it.end(), C_VS_TEST_ARR2)
|
||||
ASSERT(string_res.v1i._size == VS_TEST_ARR1_LEN)
|
||||
ASSERT(string_res.v2i._size == VS_TEST_ARR2_LEN)
|
||||
ASSERT_ARR_EQ(string_res.v1i.begin(), string_res.v1i.end(), C_VS_TEST_ARR1)
|
||||
ASSERT_ARR_EQ(string_res.v2i.begin(), string_res.v2i.end(), C_VS_TEST_ARR2)
|
||||
|
||||
ASSERT(obj_res.v1v._size == VO_TEST_ARR1_LEN)
|
||||
ASSERT(obj_res.v2v._size == VO_TEST_ARR2_LEN)
|
||||
ASSERT_ALL_EQ(obj_res.v1v.begin(), obj_res.v1v.end(), C_VO_TEST_ARR1[0])
|
||||
ASSERT_ALL_EQ(obj_res.v2v.begin(), obj_res.v2v.end(), C_VO_TEST_ARR2[0])
|
||||
ASSERT(obj_res.vvo._size == obj_res.vvo._len)
|
||||
ASSERT_ALL_EQ(obj_res.vvo.begin(), obj_res.vvo.end(), C_VO_TEST_ARR1[0])
|
||||
ASSERT(obj_res.v1it._size == VO_TEST_ARR1_LEN)
|
||||
ASSERT(obj_res.v2it._size == VO_TEST_ARR2_LEN)
|
||||
ASSERT_ARR_EQ(obj_res.v1it.begin(), obj_res.v1it.end(), C_VO_TEST_ARR1)
|
||||
ASSERT_ARR_EQ(obj_res.v2it.begin(), obj_res.v2it.end(), C_VO_TEST_ARR2)
|
||||
ASSERT(obj_res.v1i._size == VO_TEST_ARR1_LEN)
|
||||
ASSERT(obj_res.v2i._size == VO_TEST_ARR2_LEN)
|
||||
ASSERT_ARR_EQ(obj_res.v1i.begin(), obj_res.v1i.end(), C_VO_TEST_ARR1)
|
||||
ASSERT_ARR_EQ(obj_res.v2i.begin(), obj_res.v2i.end(), C_VO_TEST_ARR2)
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -961,6 +1064,7 @@ int main(int, char *[])
|
|||
std::cout << "Test of copy constructors: " << test_const_vector::test_constructor_copy() << std::endl;
|
||||
std::cout << "Test of move constructor: " << test_const_vector::test_constructor_move() << std::endl;
|
||||
std::cout << "Test of operator=: " << test_const_vector::test_operator_eq() << std::endl;
|
||||
std::cout << "Test of assign(): " << test_const_vector::test_assign() << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue