Add an example to the Configure trait

This commit is contained in:
Markus Westerlind
2017-11-03 16:12:43 +01:00
parent 1b9a096fa7
commit aad7a7987f
10 changed files with 157 additions and 186 deletions
+5 -9
View File
@@ -7,7 +7,7 @@
// except according to those terms.
extern crate serde_test;
use self::serde_test::{Token, assert_tokens_readable};
use self::serde_test::{assert_tokens, Configure, Token};
use std::net;
@@ -17,9 +17,8 @@ mod macros;
#[test]
fn ip_addr_roundtrip() {
assert_tokens_readable(
&net::IpAddr::from(*b"1234"),
assert_tokens(
&net::IpAddr::from(*b"1234").compact(),
&seq![
Token::NewtypeVariant { name: "IpAddr", variant: "V4" },
@@ -27,15 +26,13 @@ fn ip_addr_roundtrip() {
seq b"1234".iter().map(|&b| Token::U8(b)),
Token::TupleEnd,
],
Some(false),
);
}
#[test]
fn socked_addr_roundtrip() {
assert_tokens_readable(
&net::SocketAddr::from((*b"1234567890123456", 1234)),
assert_tokens(
&net::SocketAddr::from((*b"1234567890123456", 1234)).compact(),
&seq![
Token::NewtypeVariant { name: "SocketAddr", variant: "V6" },
@@ -48,6 +45,5 @@ fn socked_addr_roundtrip() {
Token::U16(1234),
Token::TupleEnd,
],
Some(false),
);
}