-
-
Notifications
You must be signed in to change notification settings - Fork 777
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
Consolidate and add new tests of internally tagged enums #2788
Merged
dtolnay
merged 22 commits into
serde-rs:master
from
Mingun:internally-tagged-enum-tests
Aug 15, 2024
Merged
Consolidate and add new tests of internally tagged enums #2788
dtolnay
merged 22 commits into
serde-rs:master
from
Mingun:internally-tagged-enum-tests
Aug 15, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mingun
force-pushed
the
internally-tagged-enum-tests
branch
from
August 13, 2024 17:06
3bbc95c
to
543feb0
Compare
(review this commit with "ignore whitespace changes" option on)
…ed module Moved: - test_internally_tagged_enum_with_untagged_variant => untagged_variant - test_internally_tagged_bytes => string_and_bytes mod - test_internally_tagged_struct_variant_containing_unit_variant => struct_variant_containing_unit_variant - test_internally_tagged_borrow => borrow - test_enum_in_internally_tagged_enum => newtype_variant_containing_externally_tagged_enum - test_internally_tagged_newtype_variant_containing_unit_struct => newtype_variant_containing_unit_struct (review this commit with "ignore whitespace changes" option on)
Ctrl+X, Ctrl+V
Moved all except flattened tests: - test_internally_tagged_enum_with_skipped_conflict => with_skipped_conflict - test_internally_tagged_enum_new_type_with_unit => newtype_variant_containing_unit - test_internally_tagged_unit_enum_with_unknown_fields => unit_variant_with_unknown_fields - test_expecting_message_internally_tagged_enum => expecting_message - flatten::enum_::internally_tagged::straightforward => containing_flatten
…ct_variant_containing_unit_variant
- newtype_variant_containing_unit -> newtype_unit - newtype_variant_containing_unit_struct -> newtype_unit_struct - newtype_variant_containing_externally_tagged_enum -> newtype_enum - struct_variant_containing_unit_variant -> struct_enum
Separate testing each variant kind of enum (unit, newtype, tuple, struct) results in more specific information if that checks fail (review this commit with "ignore whitespace changes" option on)
Special case is the tag field first (so the enum variant are known after reading the first entry from map). General case is the tag field not the first (so we need to buffer entries until we found an entry with tag)
- check that unit variant can be deserialized from a map - check that newtype variant with unit can be deserialized from a struct
Mingun
force-pushed
the
internally-tagged-enum-tests
branch
from
August 15, 2024 18:42
543feb0
to
2adb0e9
Compare
dtolnay
approved these changes
Aug 15, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This was referenced Aug 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The goal of this PR is to improve test coverage by testing corner cases that could be break during refactorings and implementing optimizations.
This PR moves all tests for internally tagged enums (those which is defined using
#[serde(tag = "tag")]
attribute) into a dedicated file, removes duplicated tests and organize tests in a logical manner.This PR does not add tests which is failed without changes in
serde_text
or inserde
(they are left in #2569). So only refactoring of existing tests and a new tests that already passes.