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