From a765ab37c1a2fedd923ec5a5665f8beca04908b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20T=C3=BCz=C3=BCn?= Date: Thu, 2 Nov 2023 22:27:05 +0300 Subject: [PATCH] Added test inserting existing value to full set --- test/test_set.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/test_set.cpp b/test/test_set.cpp index aa25fc2a6..41be506c8 100644 --- a/test/test_set.cpp +++ b/test/test_set.cpp @@ -594,6 +594,51 @@ namespace CHECK_EQUAL(4, data.find(ItemM(4))->value); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_existing_value_when_full) + { + Compare_Data compare_data; + Data data; + ETL_OR_STD::pair data_result; + ETL_OR_STD::pair compare_result; + + for (size_t i = 0; i < MAX_SIZE; ++i) + { + data_result = data.insert(i); + compare_result = compare_data.insert(i); + + // Check that both return successful return results + CHECK_EQUAL(*data_result.first, *compare_result.first); + } + + // Try to insert when set is full should throw etl::set_full + try + { + data_result = data.insert(MAX_SIZE); + } + catch(const etl::set_full &e) + {} + + // Try adding a duplicate (should return iterator pointing to duplicate) not throw error + for (size_t i = 0; i < MAX_SIZE; ++i) + { + data_result = data.insert(i); + compare_result = compare_data.insert(i); + + // Check that both return successful return results + CHECK_EQUAL(*data_result.first, *compare_result.first); + } + + + + // Check that elements in set are the same + bool isEqual = Check_Equal(data.begin(), + data.end(), + compare_data.begin()); + CHECK(isEqual); + + } + //************************************************************************* //TEST_FIXTURE(SetupFixture, test_emplace_value) //{