Skip to content

Commit

Permalink
Added test inserting existing value to full set
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailtzn committed Nov 2, 2023
1 parent 4ba432e commit a765ab3
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/test_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::iterator, bool> data_result;
ETL_OR_STD::pair<Compare_Data::iterator, bool> 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)
//{
Expand Down

0 comments on commit a765ab3

Please sign in to comment.