mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-22 21:48:02 +00:00
Fix handling of option and newtype in IgnoredAny
This commit is contained in:
@@ -35,6 +35,9 @@ mod macros;
|
||||
#[derive(Copy, Clone, PartialEq, Debug, Deserialize)]
|
||||
struct UnitStruct;
|
||||
|
||||
#[derive(PartialEq, Debug, Deserialize)]
|
||||
struct NewtypeStruct(i32);
|
||||
|
||||
#[derive(PartialEq, Debug, Deserialize)]
|
||||
struct TupleStruct(i32, i32, i32);
|
||||
|
||||
@@ -166,13 +169,6 @@ fn assert_de_tokens_ignore(ignorable_tokens: &[Token]) {
|
||||
let mut de = serde_test::Deserializer::new(&concated_tokens);
|
||||
let v: Result<IgnoreBase, Error> = Deserialize::deserialize(&mut de);
|
||||
|
||||
// We run this test on every token stream for convenience, but
|
||||
// some token streams don't make sense embedded as a map value,
|
||||
// so we ignore those. SyntaxError is the real sign of trouble.
|
||||
if let Err(Error::UnexpectedToken(_)) = v {
|
||||
return;
|
||||
}
|
||||
|
||||
assert_eq!(v.as_ref(), Ok(&expected));
|
||||
assert_eq!(de.next_token(), None);
|
||||
}
|
||||
@@ -225,7 +221,6 @@ declare_tests! {
|
||||
test_option {
|
||||
None::<i32> => &[Token::Unit],
|
||||
None::<i32> => &[Token::Option(false)],
|
||||
Some(1) => &[Token::I32(1)],
|
||||
Some(1) => &[
|
||||
Token::Option(true),
|
||||
Token::I32(1),
|
||||
@@ -260,6 +255,12 @@ declare_tests! {
|
||||
Token::SeqEnd,
|
||||
],
|
||||
}
|
||||
test_newtype_struct {
|
||||
NewtypeStruct(1) => &[
|
||||
Token::StructNewType("NewtypeStruct"),
|
||||
Token::I32(1),
|
||||
],
|
||||
}
|
||||
test_tuple_struct {
|
||||
TupleStruct(1, 2, 3) => &[
|
||||
Token::SeqStart(Some(3)),
|
||||
|
||||
Reference in New Issue
Block a user