Skip to content

Commit

Permalink
Update tests to cover both const and non-const version of remove()
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Lesiak authored and mikelik committed May 18, 2023
1 parent 2b0fd5c commit a1aae5f
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions tests/unit/test_contracts/multi_index_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ namespace _test_multi_index
eosio::check(itr2 == table.end(), "idx64_general - table.erase()");
}

// insert, update and delete by iterator
// insert, update and remove by iterator
{
const uint64_t ssn = 421;
auto new_person = table.insert(payer, [&](auto &r)
Expand All @@ -224,7 +224,7 @@ namespace _test_multi_index
eosio::check(itr2 == table.end(), "idx64_general - table.remove()");
}

// insert, update and delete by object
// insert, update and remove by object
{
const uint64_t ssn = 421;
auto new_person = table.insert(payer, [&](auto &r)
Expand All @@ -235,7 +235,26 @@ namespace _test_multi_index
table.update(new_person, payer, [&](auto &r)
{ r.sec = "billy"_n.value; });

table.remove(new_person);
const auto& person_object = table.get(ssn);
auto& mutable_person = const_cast<record&>(person_object);
table.remove(mutable_person);
auto itr2 = table.find(ssn);
eosio::check(itr2 == table.end(), "idx64_general - table.remove()");
}

// insert, update and remove by const object
{
const uint64_t ssn = 421;
auto new_person = table.insert(payer, [&](auto &r)
{
r.id = ssn;
r.sec = "bob"_n.value; });

table.update(new_person, payer, [&](auto &r)
{ r.sec = "billy"_n.value; });

const auto& person_object = table.get(ssn);
table.remove(person_object);
auto itr2 = table.find(ssn);
eosio::check(itr2 == table.end(), "idx64_general - table.remove()");
}
Expand Down

0 comments on commit a1aae5f

Please sign in to comment.