[vector] Allow to iterate with mutables (#7586)

Co-authored-by: ArnaudD-FR <arnaud.desmier@gmail.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
ArnaudD-FR
2022-10-21 21:10:18 +02:00
committed by GitHub
parent 872a497464
commit 5b3fadcc16
4 changed files with 30 additions and 6 deletions

View File

@@ -439,6 +439,16 @@ void MutateFlatBuffersTest(uint8_t *flatbuf, std::size_t length) {
TEST_EQ(first->hp(), 0);
first->mutate_hp(1000);
// Test for each loop over mutable entries
for (auto item: *tables)
{
TEST_EQ(item->hp(), 1000);
item->mutate_hp(0);
TEST_EQ(item->hp(), 0);
item->mutate_hp(1000);
break; // one iteration is enough, just testing compilation
}
// Mutate via LookupByKey
TEST_NOTNULL(tables->MutableLookupByKey("Barney"));
TEST_EQ(static_cast<Monster *>(nullptr),