From c2d828cfb9b722ed5470410b47e570ec014593df Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 29 Jul 2024 17:23:01 +0200 Subject: [PATCH] added tests for erase() --- .../const_vector_data_augmentation.test.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/const_vector/const_vector_data_augmentation.test.cpp b/test/const_vector/const_vector_data_augmentation.test.cpp index dbeb420..5e6bcb0 100644 --- a/test/const_vector/const_vector_data_augmentation.test.cpp +++ b/test/const_vector/const_vector_data_augmentation.test.cpp @@ -269,6 +269,32 @@ constexpr test_suite tests = define_tests("Data Augmentation") return TEST_PASS(); }), 2, int, char, const char *, TestObj); + return TEST_PASS(); + }, EvalFlag::RUNTIME_CONSTEVAL) + + ("const_vector::erase()", []() constexpr { + + REPEAT_FOR_TYPES_N(([]() constexpr { + + cc::const_vector v = get_test_param(); + + 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 comparable; + std::ranges::copy(get_test_param(), 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);