2018-12-31 20:44:24 -06:00
|
|
|
use serde_test::{assert_tokens, Configure, Token};
|
2017-09-14 09:54:47 -05:00
|
|
|
use std::net;
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
#[allow(unused_macros)]
|
|
|
|
mod macros;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn ip_addr_roundtrip() {
|
2017-11-03 10:12:43 -05:00
|
|
|
assert_tokens(
|
|
|
|
&net::IpAddr::from(*b"1234").compact(),
|
2017-09-14 09:54:47 -05:00
|
|
|
&seq![
|
2022-01-20 21:25:06 -06:00
|
|
|
Token::NewtypeVariant {
|
|
|
|
name: "IpAddr",
|
|
|
|
variant: "V4"
|
|
|
|
},
|
2017-09-14 09:54:47 -05:00
|
|
|
Token::Tuple { len: 4 },
|
2022-01-20 21:36:41 -06:00
|
|
|
b"1234".iter().copied().map(Token::U8),
|
2017-09-14 09:54:47 -05:00
|
|
|
Token::TupleEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2018-01-03 08:16:45 -06:00
|
|
|
fn socket_addr_roundtrip() {
|
2017-11-03 10:12:43 -05:00
|
|
|
assert_tokens(
|
|
|
|
&net::SocketAddr::from((*b"1234567890123456", 1234)).compact(),
|
2017-09-14 09:54:47 -05:00
|
|
|
&seq![
|
2022-01-20 21:25:06 -06:00
|
|
|
Token::NewtypeVariant {
|
|
|
|
name: "SocketAddr",
|
|
|
|
variant: "V6"
|
|
|
|
},
|
2017-09-14 09:54:47 -05:00
|
|
|
Token::Tuple { len: 2 },
|
|
|
|
Token::Tuple { len: 16 },
|
2022-01-20 21:36:41 -06:00
|
|
|
b"1234567890123456".iter().copied().map(Token::U8),
|
2017-09-14 09:54:47 -05:00
|
|
|
Token::TupleEnd,
|
|
|
|
Token::U16(1234),
|
|
|
|
Token::TupleEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|