From 21adee8f408b71add3f65f3f19bc49a88c8ae800 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 5 Apr 2017 01:15:42 -0700 Subject: [PATCH] Partial support for EnumStart in assert_ser_tokens --- serde_test/src/ser.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/serde_test/src/ser.rs b/serde_test/src/ser.rs index 1a105f33..e8af6ee9 100644 --- a/serde_test/src/ser.rs +++ b/serde_test/src/ser.rs @@ -149,7 +149,13 @@ impl<'s, 'a> ser::Serializer for &'s mut Serializer<'a> { _variant_index: usize, variant: &'static str) -> Result<(), Error> { - assert_next_token!(self, EnumUnit(name, variant)); + if self.tokens.first() == Some(&Token::EnumStart(name)) { + self.next_token(); + assert_next_token!(self, Str(variant)); + assert_next_token!(self, Unit); + } else { + assert_next_token!(self, EnumUnit(name, variant)); + } Ok(()) } @@ -168,7 +174,12 @@ impl<'s, 'a> ser::Serializer for &'s mut Serializer<'a> { -> Result<(), Error> where T: Serialize { - assert_next_token!(self, EnumNewType(name, variant)); + if self.tokens.first() == Some(&Token::EnumStart(name)) { + self.next_token(); + assert_next_token!(self, Str(variant)); + } else { + assert_next_token!(self, EnumNewType(name, variant)); + } value.serialize(self) }