diff --git a/test/const_vector/const_vector_data_access.test.cpp b/test/const_vector/const_vector_data_access.test.cpp index 9dcb072..82fbe65 100644 --- a/test/const_vector/const_vector_data_access.test.cpp +++ b/test/const_vector/const_vector_data_access.test.cpp @@ -26,6 +26,137 @@ constexpr test_suite tests = define_tests("Data Access") return TEST_PASS(); }), 2, int, char, const char *, TestObj); + return TEST_PASS(); + }, EvalFlag::RUNTIME_CONSTEVAL) + ("const_vector::operator[](size_type pos)", []() constexpr { + + REPEAT_FOR_TYPES_N(([]() constexpr { + + cc::const_vector()) + 1> v(get_test_param()); + const cc::const_vector()) + 1> cv(get_test_param()); + + for (int i = 0; i < c_arr_len(get_test_param()); ++i) { + ASSERT((v[i] == get_test_param()[i]), ctx); + ASSERT((cv[i] == get_test_param()[i]), ctx); + } + + v[v.size() / 2] = get_test_param(); + + ASSERT((v[v.size() / 2] == get_test_param()), ctx); + + return TEST_PASS(); + }), 2, int, char, const char *, TestObj); + + return TEST_PASS(); + }, EvalFlag::RUNTIME_CONSTEVAL) + ("const_vector::front()", []() constexpr { + + REPEAT_FOR_TYPES_N(([]() constexpr { + + cc::const_vector()) + 1> v(get_test_param()); + const cc::const_vector()) + 1> cv(get_test_param()); + + ASSERT((v.front() == get_test_param()[0]), ctx); + ASSERT((cv.front() == get_test_param()[0]), ctx); + + v.front() = get_test_param(); + ASSERT((v[0] == get_test_param())); + + return TEST_PASS(); + }), 2, int, char, const char *, TestObj); + + return TEST_PASS(); + }, EvalFlag::RUNTIME_CONSTEVAL) + ("const_vector::back()", []() constexpr { + + REPEAT_FOR_TYPES_N(([]() constexpr { + + cc::const_vector()) + 1> v(get_test_param()); + const cc::const_vector()) + 1> cv(get_test_param()); + + ASSERT((v.back() == get_test_param()[c_arr_len(get_test_param()) - 1]), ctx); + ASSERT((cv.back() == get_test_param()[c_arr_len(get_test_param()) - 1]), ctx); + + v.back() = get_test_param(); + ASSERT((v[v.size() - 1] == get_test_param())); + + return TEST_PASS(); + }), 2, int, char, const char *, TestObj); + + return TEST_PASS(); + }, EvalFlag::RUNTIME_CONSTEVAL) + ("const_vector::(c)begin()/(c)end()", []() constexpr { + + REPEAT_FOR_TYPES_N(([]() constexpr { + + cc::const_vector()) + 1> v(get_test_param()); + const cc::const_vector()) + 1> cv(get_test_param()); + + auto v_it = v.begin(); + for (std::size_t i = 0; v_it != v.end(); ++v_it, ++i) { + ASSERT(*v_it == v[i], ctx); + *v_it = get_test_param(); + ASSERT((v[i] == get_test_param()), ctx); + } + + auto v_cit = v.cbegin(); + for (std::size_t i = 0; v_cit != v.cend(); ++v_cit, ++i) { + ASSERT(*v_cit == v[i], ctx); + ASSERT(std::is_const_v::reference>>, ctx); + } + + auto cv_it = cv.begin(); + for (std::size_t i = 0; cv_it != cv.end(); ++cv_it, ++i) { + ASSERT(*cv_it == cv[i], ctx); + ASSERT(std::is_const_v::reference>>, ctx); + } + + auto cv_cit = cv.cbegin(); + for (std::size_t i = 0; cv_cit != cv.cend(); ++cv_cit, ++i) { + ASSERT(*cv_cit == cv[i], ctx); + ASSERT(std::is_const_v::reference>>, ctx); + } + + return TEST_PASS(); + }), 2, int, char, const char *, TestObj); + + return TEST_PASS(); + }, EvalFlag::RUNTIME_CONSTEVAL) + ("const_vector::(c)rbegin()/(c)rend()", []() constexpr { + + REPEAT_FOR_TYPES_N(([]() constexpr { + + cc::const_vector()) + 1> v(get_test_param()); + const cc::const_vector()) + 1> cv(get_test_param()); + + auto v_it = v.rbegin(); + for (std::size_t i = v.size() - 1; v_it != v.rend(); ++v_it, --i) { + ASSERT(*v_it == v[i], ctx); + *v_it = get_test_param(); + ASSERT((v[i] == get_test_param()), ctx); + } + + auto v_cit = v.crbegin(); + for (std::size_t i = v.size() - 1; v_cit != v.crend(); ++v_cit, --i) { + ASSERT(*v_cit == v[i], ctx); + ASSERT(std::is_const_v::reference>>, ctx); + } + + auto cv_it = cv.rbegin(); + for (std::size_t i = v.size() - 1; cv_it != cv.rend(); ++cv_it, --i) { + ASSERT(*cv_it == cv[i], ctx); + ASSERT(std::is_const_v::reference>>, ctx); + } + + auto cv_cit = cv.crbegin(); + for (std::size_t i = v.size() - 1; cv_cit != cv.crend(); ++cv_cit, --i) { + ASSERT(*cv_cit == cv[i], ctx); + ASSERT(std::is_const_v::reference>>, ctx); + } + + return TEST_PASS(); + }), 2, int, char, const char *, TestObj); + return TEST_PASS(); }, EvalFlag::RUNTIME_CONSTEVAL);