mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-22 21:48:02 +00:00
Remove redundant readable/compact tests
This functionality is covered well enough by the std::net types.
This commit is contained in:
@@ -1170,40 +1170,3 @@ declare_error_tests! {
|
||||
"invalid type: sequence, expected unit struct UnitStruct",
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct CompactBinary((u8, u8));
|
||||
|
||||
impl<'de> serde::Deserialize<'de> for CompactBinary {
|
||||
fn deserialize<D>(deserializer: D) -> Result<CompactBinary, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
if deserializer.is_human_readable() {
|
||||
<(u8, u8)>::deserialize(deserializer).map(CompactBinary)
|
||||
} else {
|
||||
<&[u8]>::deserialize(deserializer).map(|bytes| {
|
||||
CompactBinary((bytes[0], bytes[1]))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_human_readable() {
|
||||
assert_de_tokens_readable(
|
||||
&CompactBinary((1, 2)),
|
||||
&[
|
||||
Token::Tuple { len: 2},
|
||||
Token::U8(1),
|
||||
Token::U8(2),
|
||||
Token::TupleEnd,
|
||||
],
|
||||
Some(true),
|
||||
);
|
||||
assert_de_tokens_readable(
|
||||
&CompactBinary((1, 2)),
|
||||
&[Token::BorrowedBytes(&[1, 2])],
|
||||
Some(false),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user