1 use serde_test::{assert_tokens, Configure, Token};
2 use std::net;
3
4 #[macro_use]
5 #[allow(unused_macros)]
6 mod macros;
7
8 #[test]
ip_addr_roundtrip()9 fn ip_addr_roundtrip() {
10 assert_tokens(
11 &net::IpAddr::from(*b"1234").compact(),
12 &seq![
13 Token::NewtypeVariant {
14 name: "IpAddr",
15 variant: "V4"
16 },
17 Token::Tuple { len: 4 },
18 b"1234".iter().copied().map(Token::U8),
19 Token::TupleEnd,
20 ],
21 );
22 }
23
24 #[test]
socket_addr_roundtrip()25 fn socket_addr_roundtrip() {
26 assert_tokens(
27 &net::SocketAddr::from((*b"1234567890123456", 1234)).compact(),
28 &seq![
29 Token::NewtypeVariant {
30 name: "SocketAddr",
31 variant: "V6"
32 },
33 Token::Tuple { len: 2 },
34 Token::Tuple { len: 16 },
35 b"1234567890123456".iter().copied().map(Token::U8),
36 Token::TupleEnd,
37 Token::U16(1234),
38 Token::TupleEnd,
39 ],
40 );
41 }
42