Commit Graph

4040 Commits

Author SHA1 Message Date
Mingun
c383e4f953 Tuple: add tests for deserialization from sequence
(review this commit with "ignore whitespace changes" option on)
2024-08-16 22:51:16 +05:00
Mingun
a94d8750fb Newtype: move up the test with tag only 2024-08-16 22:51:13 +05:00
Mingun
b0d651be40 Newtype: add tests for deserialization from sequence
(review this commit with "ignore whitespace changes" option on)
2024-08-16 22:51:13 +05:00
Mingun
d5a9c11b5c No need to test integer and byte array field names, they already tested for Unit case
There is no difference what variant is deserialized so we can test only one kind of variant
2024-08-16 22:51:10 +05:00
Mingun
6bfe1c435a Unit: add tests for deserialization from bytes tag and content fields 2024-08-16 22:43:15 +05:00
Mingun
a02da49b87 Unit: add tests for deserialization from integer tag and content fields 2024-08-16 22:43:15 +05:00
Mingun
29dc6c3367 Unit: add tests for deserialization from sequence
(review this commit with "ignore whitespace changes" option on)
2024-08-16 22:38:02 +05:00
Mingun
a7f0bab078 Document fields in internal structs used to deserialize adjacently tagged enums 2024-08-16 21:39:55 +05:00
Mingun
3dc6829303 Integrate bytes test into struct_ test
`newtype` test also integrates test with `Bytes` tag, so be like

Removed the first assert_tokens because it is the same as the first assert in the merged method
2024-08-16 21:39:53 +05:00
Mingun
42e63ff942 Reuse AdjacentlyTagged enum in bytes test
Change 0i32 to 1u8 so the test can be merged with the previous in the next commit
2024-08-16 21:38:23 +05:00
Mingun
df07751e6f Group newtype and newtype_with_newtype tests 2024-08-16 21:36:56 +05:00
Mingun
5445f1741b Reuse AdjacentlyTagged enum in newtype_with_newtype test 2024-08-16 21:36:56 +05:00
Mingun
9d0f811221 Remove unnecessary generic 2024-08-16 21:36:56 +05:00
Mingun
36b9a859c4 Test deserialization of the serialized unit format for adjacently tagged enum 2024-08-16 21:36:55 +05:00
Mingun
59628d1712 Create only one value for all checks 2024-08-16 21:36:55 +05:00
Mingun
bee7470715 Split test test_adjacently_tagged_enum into four tests for each variant
(review this commit with "ignore whitespace changes" option on)
2024-08-16 21:36:55 +05:00
Mingun
5a359e10f4 Group Newtype variant checks in test_adjacently_tagged_enum together 2024-08-16 21:36:55 +05:00
Mingun
5e37ade519 Move all adjacently tagged enum tests (except flatten) into a dedicated module
Moved and renamed:
From test_annotatons
- test_adjacently_tagged_enum_bytes               => bytes
- flatten::enum_::adjacently_tagged::straitforward=> struct_with_flatten
- test_expecting_message_adjacently_tagged_enum   => expecting_message
- test_partially_untagged_adjacently_tagged_enum  => partially_untagged

From test_macros
- test_adjacently_tagged_newtype_struct           => newtype_with_newtype
- test_adjacently_tagged_enum
- test_adjacently_tagged_enum_deny_unknown_fields => deny_unknown_fields
2024-08-16 21:36:52 +05:00
David Tolnay
1a9ffdbd0c
Merge pull request #2788 from Mingun/internally-tagged-enum-tests
Consolidate and add new tests of internally tagged enums
2024-08-15 14:42:28 -07:00
Mingun
2adb0e99b0 Add additional checks for unit and newtype_unit tests
- check that unit variant can be deserialized from a map
- check that newtype variant with unit can be deserialized from a struct
2024-08-15 23:39:14 +05:00
Mingun
71ed1f2f12 Add tests for special and general cases for internally tagged enums
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)
2024-08-15 23:39:13 +05:00
Mingun
47954502af Add tests with borrowed strings for the tag field name and tag value 2024-08-15 23:39:13 +05:00
Mingun
4987fd15f7 Convert newtype_enum and struct_enum tests into modules
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)
2024-08-15 23:39:12 +05:00
Mingun
8bfe0d0ac0 Move and rename tests:
- 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
2024-08-15 23:39:12 +05:00
Mingun
7c0e6bd18f Reuse type in struct_variant_containing_unit_variant 2024-08-15 23:39:11 +05:00
Mingun
41b9c33c2b Reuse type in newtype_variant_containing_externally_tagged_enum 2024-08-15 23:39:11 +05:00
Mingun
28a775db22 Share externally tagged enum Enum between all tests and reuse in struct_variant_containing_unit_variant 2024-08-15 23:39:10 +05:00
Mingun
e999600f8f Rename externally tagged enum Inner to Enum 2024-08-15 23:39:10 +05:00
Mingun
d3492d8d36 Reuse type in newtype_variant_containing_unit_struct 2024-08-15 23:39:09 +05:00
Mingun
48de0c51b0 Share unit struct Unit between all tests 2024-08-15 23:39:09 +05:00
Mingun
93bda5f1dc Rename unit struct to a generic name: Info->Unit 2024-08-15 23:39:09 +05:00
Mingun
2d75ef6b30 Reuse type in newtype_variant_containing_unit 2024-08-15 23:39:07 +05:00
Mingun
f97160f715 Reuse type in unit_variant_with_unknown_fields and add test for sequence 2024-08-15 23:39:06 +05:00
Mingun
eb59c776ca Use name "tag" to refer to tag field 2024-08-15 23:39:06 +05:00
Mingun
9128201c78 Use the same order of derives 2024-08-15 23:39:05 +05:00
Mingun
2cbfd37072 Move all other internally tagged enum tests into a dedicated file
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
2024-08-15 23:39:05 +05:00
Mingun
0939214c51 Move internally tagged enum tests into a dedicated file
Ctrl+X, Ctrl+V
2024-08-15 23:34:01 +05:00
Mingun
8c60f5aea7 Reorder enum variants and tests to canonical order (Unit, Newtype, Tuple, Struct) 2024-08-15 23:34:00 +05:00
Mingun
da0ed4021d Give meaningful names to enum variants 2024-08-15 23:34:00 +05:00
Mingun
99f905403b Move all internally tagged enum tests of test_macros into a dedicated 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)
2024-08-15 23:34:00 +05:00
Mingun
aa0654332d Convert test_internally_tagged_enum into module
(review this commit with "ignore whitespace changes" option on)
2024-08-15 23:33:59 +05:00
David Tolnay
af376c22c3
Merge pull request #2803 from jonhoo/mv-flatten-tests
Group flatten tests
2024-08-15 10:53:49 -07:00
Jon Gjengset
477eb7b70e
Group flatten tests 2024-08-15 18:28:49 +02:00
David Tolnay
026e91a68c
Release 1.0.208 2024-08-15 08:41:27 -07:00
David Tolnay
bfbedac919
Merge pull request #2802 from jonhoo/flatten-unit-struct
Support (de-)serializing flattened unit struct
2024-08-15 08:40:11 -07:00
Jon Gjengset
4036ff88ed
Support (de-)serializing flattened unit struct
Fixes #2801.
2024-08-15 15:50:54 +02:00
David Tolnay
1b4da41f97
Release 1.0.207 2024-08-12 13:06:46 -07:00
David Tolnay
f61d452814
Touch up PR 2795 2024-08-12 13:03:10 -07:00
David Tolnay
f9866097a0
Merge pull request #2795 from Mingun/has-flatten-rework
`has_flatten` rework
2024-08-12 13:02:58 -07:00
Mingun
77a6a9d4e1 Take into account only not skipped flatten fields when choose serialization form
Consequence: `FlattenSkipSerializing`
- uses `serialize_struct` instead of `serialize_map`
2024-08-11 20:12:09 +05:00