Makes VectorIterator compatible with STL iterators. (#4768)

This commit is contained in:
Vladimir Glavnyy
2018-06-05 02:02:08 +07:00
committed by Wouter van Oortmerssen
parent ecc07e7793
commit c7a797b966
2 changed files with 9 additions and 4 deletions

View File

@@ -273,8 +273,13 @@ void AccessFlatBufferTest(const uint8_t *flatbuf, size_t length,
TEST_EQ(VectorLength(inventory), 10UL); // Works even if inventory is null.
TEST_NOTNULL(inventory);
unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
for (auto it = inventory->begin(); it != inventory->end(); ++it)
TEST_EQ(*it, inv_data[it - inventory->begin()]);
// Check compatibilty of iterators with STL.
std::vector<unsigned char> inv_vec(inventory->begin(), inventory->end());
for (auto it = inventory->begin(); it != inventory->end(); ++it) {
auto indx = it - inventory->begin();
TEST_EQ(*it, inv_vec.at(indx)); // Use bounds-check.
TEST_EQ(*it, inv_data[indx]);
}
TEST_EQ(monster->color(), Color_Blue);