Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect message in serializer tokens and correctly implement next_entry_seed #1918

Merged
merged 2 commits into from Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions serde_test/src/configure.rs
Expand Up @@ -777,6 +777,17 @@ macro_rules! impl_deserializer {
{
self.0.next_value_seed($wrapper(seed))
}
fn next_entry_seed<K, V>(
&mut self,
kseed: K,
vseed: V,
) -> Result<Option<(K::Value, V::Value)>, D::Error>
where
K: DeserializeSeed<'de>,
V: DeserializeSeed<'de>,
{
self.0.next_entry_seed($wrapper(kseed), $wrapper(vseed))
}
fn size_hint(&self) -> Option<usize> {
self.0.size_hint()
}
Expand Down
26 changes: 13 additions & 13 deletions serde_test/src/ser.rs
Expand Up @@ -32,18 +32,18 @@ impl<'a> Serializer<'a> {
}

macro_rules! assert_next_token {
($ser:expr, $expected:ident) => {
assert_next_token!($ser, stringify!($expected), Token::$expected, true);
($ser:expr, $actual:ident) => {
assert_next_token!($ser, stringify!($actual), Token::$actual, true);
};
($ser:expr, $expected:ident($v:expr)) => {
($ser:expr, $actual:ident($v:expr)) => {
assert_next_token!(
$ser,
format_args!(concat!(stringify!($expected), "({:?})"), $v),
Token::$expected(v),
format_args!(concat!(stringify!($actual), "({:?})"), $v),
Token::$actual(v),
v == $v
);
};
($ser:expr, $expected:ident { $($k:ident),* }) => {
($ser:expr, $actual:ident { $($k:ident),* }) => {
let compare = ($($k,)*);
let field_format = || {
use std::fmt::Write;
Expand All @@ -55,21 +55,21 @@ macro_rules! assert_next_token {
};
assert_next_token!(
$ser,
format_args!(concat!(stringify!($expected), " {{ {}}}"), field_format()),
Token::$expected { $($k),* },
format_args!(concat!(stringify!($actual), " {{ {}}}"), field_format()),
Token::$actual { $($k),* },
($($k,)*) == compare
);
};
($ser:expr, $expected:expr, $pat:pat, $guard:expr) => {
($ser:expr, $actual:expr, $pat:pat, $guard:expr) => {
match $ser.next_token() {
Some($pat) if $guard => {}
Some(other) => {
Some(expected) => {
panic!("expected Token::{} but serialized as {}",
$expected, other);
expected, $actual);
}
None => {
panic!("expected Token::{} after end of serialized tokens",
$expected);
panic!("expected end of tokens, but {} was serialized",
$actual);
}
}
};
Expand Down