33 #include <unordered_map>
39 #include <google/protobuf/map_unittest.pb.h>
40 #include <google/protobuf/unittest.pb.h>
53 using unittest::TestAllTypes;
85 int size()
const override {
return 0; }
94 const MapIterator& other_iterator)
const override {}
100 typedef unittest::TestMap_MapInt32Int32Entry_DoNotUse
EntryType;
108 ->FindFieldByName(
"map_int32_int32")
133 EXPECT_LT(0, map_field_base_->SpaceUsedExcludingSelf());
139 map_field_base_->GetRepeatedField());
141 for (
int i = 0;
i < repeated.
size();
i++) {
152 map_field_base_->MutableRepeatedField());
154 for (
int i = 0;
i < repeated->
size();
i++) {
164 std::vector<char> arena_block(128 * 1024);
166 options.initial_block = &arena_block[0];
167 options.initial_block_size = arena_block.size();
175 MapFieldType* map_field = Arena::CreateMessage<MapFieldType>(&arena);
178 (*map_field->MutableMap())[100] = 101;
181 map_field->GetRepeatedField();
190 Arena::CreateMessage<MapFieldBaseStub>(&arena);
198 enum State { CLEAN, MAP_DIRTY, REPEATED_DIRTY };
204 typedef unittest::TestMap_MapInt32Int32Entry_DoNotUse
EntryType;
234 Expect(map_field, CLEAN, 1, 1,
false);
240 Expect(map_field, MAP_DIRTY, 1, 0,
true);
251 Expect(map_field, REPEATED_DIRTY, 0, 1,
false);
255 int repeated_size,
bool is_repeated_null) {
282 if (is_repeated_null) {
303 if (state_ != MAP_DIRTY) {
312 if (state_ != MAP_DIRTY) {
321 AddOneStillClean(&other);
325 if (state_ != MAP_DIRTY) {
331 Expect(&other, CLEAN, 1, 1,
false);
336 MakeMapDirty(&other);
340 if (state_ != MAP_DIRTY) {
346 Expect(&other, MAP_DIRTY, 1, 0,
true);
351 MakeRepeatedDirty(&other);
355 if (state_ != MAP_DIRTY) {
361 Expect(&other, CLEAN, 1, 1,
false);
366 AddOneStillClean(&other);
374 Expect(&other, CLEAN, 1, 1,
false);
377 Expect(&other, MAP_DIRTY, 1, 0,
true);
380 Expect(&other, REPEATED_DIRTY, 0, 1,
false);
389 MakeMapDirty(&other);
397 Expect(&other, CLEAN, 1, 1,
false);
400 Expect(&other, MAP_DIRTY, 1, 0,
true);
403 Expect(&other, REPEATED_DIRTY, 0, 1,
false);
412 MakeRepeatedDirty(&other);
420 Expect(&other, CLEAN, 1, 1,
false);
423 Expect(&other, MAP_DIRTY, 1, 0,
true);
426 Expect(&other, REPEATED_DIRTY, 0, 1,
false);
440 map_field_base_->SpaceUsedExcludingSelf();
458 map_field_base_->GetRepeatedField();
460 if (state_ != REPEATED_DIRTY) {
468 map_field_base_->MutableRepeatedField();
470 if (state_ != REPEATED_DIRTY) {