Test deserialization of the serialized unit format for adjacently tagged enum

This commit is contained in:
Mingun 2024-08-11 23:03:26 +05:00 committed by Mingun
parent 59628d1712
commit 36b9a859c4

View File

@ -7,9 +7,7 @@
)] )]
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use serde_test::{ use serde_test::{assert_de_tokens, assert_de_tokens_error, assert_tokens, Token};
assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, Token,
};
#[derive(Debug, PartialEq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "t", content = "c")] #[serde(tag = "t", content = "c")]
@ -23,7 +21,7 @@ enum AdjacentlyTagged<T> {
#[test] #[test]
fn unit() { fn unit() {
// unit with no content // unit with no content
assert_ser_tokens( assert_tokens(
&AdjacentlyTagged::Unit::<u8>, &AdjacentlyTagged::Unit::<u8>,
&[ &[
Token::Struct { Token::Struct {
@ -39,7 +37,7 @@ fn unit() {
], ],
); );
// unit with no content // unit with no content and incorrect hint for number of elements
assert_de_tokens( assert_de_tokens(
&AdjacentlyTagged::Unit::<u8>, &AdjacentlyTagged::Unit::<u8>,
&[ &[