Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add map test cases to no_field_presence_test. #18120

Closed
wants to merge 1 commit into from

Conversation

copybara-service[bot]
Copy link

Add map test cases to no_field_presence_test.

Maps behave in a very interesting way if they are set to be implicit-presence
fields.

First of all they present the possibility that the key or value (or both) can
be the default zero value. When that happens, the gencode behaviour and the
reflection behaviour is actually different.

For example, gencode would not count zero entries in the map. However,
reflection APIs such as HasField will return true for zero map entry fields. In
essence, for maps, reflection behaves like explicit presence, but gencode
behaves like implicit presence.

(Note that this is not exactly intended, but it's just hard to change...)

I'm adding unit tests in no_field_presence_test to cover this quirk.

Maps behave in a very interesting way if they are set to be implicit-presence
fields.

First of all they present the possibility that the key or value (or both) can
be the default zero value. When that happens, the gencode behaviour and the
reflection behaviour is actually different.

For example, gencode would not count zero entries in the map. However,
reflection APIs such as HasField will return true for zero map entry fields. In
essence, for maps, reflection behaves like explicit presence, but gencode
behaves like implicit presence.

(Note that this is not exactly *intended*, but it's just hard to change...)

I'm adding unit tests in no_field_presence_test to cover this quirk.

PiperOrigin-RevId: 671126144
Copy link

Auto-closing Copybara pull request

@github-actions github-actions bot closed this Sep 11, 2024
@github-actions github-actions bot deleted the test_671126144 branch September 11, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant