extra_prop serde tests fixed
use crate::types::addon::{ExtraProp, OptionsLimit};
-use serde_test::{assert_de_tokens, assert_tokens, Token};
+use serde_test::{assert_de_tokens, assert_ser_tokens, Token};
#[test]
fn extra_prop() {
- assert_tokens(
+ assert_ser_tokens(
&vec![
ExtraProp {
name: "name".to_owned(),
@@ -59,20 +59,42 @@ fn extra_prop() {
],
);
assert_de_tokens(
- &ExtraProp {
+ &vec![
+ ExtraProp {
name: "name".to_owned(),
is_required: false,
options: vec![],
options_limit: OptionsLimit::default(),
},
+ ExtraProp {
+ name: "name".to_owned(),
+ is_required: false,
+ options: vec!["option".to_owned()],
+ options_limit: OptionsLimit::default(),
+ },
+ ],
&[
+ Token::Seq { len: Some(2) },
+ Token::Struct {
+ name: "ExtraProp",
+ len: 1,
+ },
+ Token::Str("name"),
+ Token::Str("name"),
+ Token::StructEnd,
Token::Struct {
name: "ExtraProp",
len: 1,
},
Token::Str("name"),
Token::Str("name"),
+ Token::Str("options"),
+ Token::Some,
+ Token::Seq { len: Some(1) },
+ Token::Str("option"),
+ Token::SeqEnd,
Token::StructEnd,
+ Token::SeqEnd,
],
);
}
