Remove redundant readable/compact tests

This functionality is covered well enough by the std::net types.
This commit is contained in:
David Tolnay 2017-10-17 23:16:17 -07:00
parent 5daf1b89a1
commit 9be3d32016
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 0 additions and 60 deletions

View File

@ -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),
);
}

View File

@ -548,26 +548,3 @@ fn test_enum_skipped() {
"the enum variant Enum::SkippedMap cannot be serialized",
);
}
struct CompactBinary(String);
impl serde::Serialize for CompactBinary {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer
{
if serializer.is_human_readable() {
serializer.serialize_str(&self.0)
} else {
serializer.serialize_bytes(self.0.as_bytes())
}
}
}
#[test]
fn test_human_readable() {
let value = CompactBinary("test".to_string());
assert_ser_tokens_readable(&value, &[Token::String("test")], Some(true));
assert_ser_tokens_readable(&value, &[Token::Bytes(b"test")], Some(false));
}