Function serde_test::assert_ser_tokens

source ยท
pub fn assert_ser_tokens<T>(value: &T, tokens: &[Token])
where T: ?Sized + Serialize,
Expand description

Asserts that value serializes to the given tokens.

#[derive(Serialize, Deserialize, PartialEq, Debug)]
struct S {
    a: u8,
    b: u8,
}

let s = S { a: 0, b: 0 };
assert_ser_tokens(
    &s,
    &[
        Token::Struct { name: "S", len: 2 },
        Token::Str("a"),
        Token::U8(0),
        Token::Str("b"),
        Token::U8(0),
        Token::StructEnd,
    ],
);