Skip to content

Commit

Permalink
Extend MapField swap test to include the unsafe swap version.
Browse files Browse the repository at this point in the history
It uses a different codepath in the MapField implementation.

PiperOrigin-RevId: 708078880
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Dec 20, 2024
1 parent efbd632 commit 47f5b75
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/google/protobuf/map_test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,13 @@ TEST_P(MapTestWithParams, SwapMapsFieldsViaReflection) {

reflection_tester.ExpectClearViaReflectionIterator(lhs);
reflection_tester.ExpectMapFieldsSetViaReflectionIterator(rhs);

if (lhs_arena == rhs_arena) {
// If they are the same arena, we can try the unsafe swap.
lhs->GetReflection()->UnsafeArenaSwapFields(lhs, rhs, fields);
reflection_tester.ExpectClearViaReflectionIterator(rhs);
reflection_tester.ExpectMapFieldsSetViaReflectionIterator(lhs);
}
}

class MapTestCodegenOrDynamic : public testing::TestWithParam<bool> {};
Expand Down

0 comments on commit 47f5b75

Please sign in to comment.