2017-10-22 18:01:19 -05:00
|
|
|
// Copyright 2017 Serde Developers
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2017-09-14 09:54:47 -05:00
|
|
|
extern crate serde_test;
|
2017-11-03 10:12:43 -05:00
|
|
|
use self::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![
|
|
|
|
Token::NewtypeVariant { name: "IpAddr", variant: "V4" },
|
|
|
|
|
|
|
|
Token::Tuple { len: 4 },
|
|
|
|
seq b"1234".iter().map(|&b| Token::U8(b)),
|
|
|
|
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![
|
|
|
|
Token::NewtypeVariant { name: "SocketAddr", variant: "V6" },
|
|
|
|
|
|
|
|
Token::Tuple { len: 2 },
|
|
|
|
|
|
|
|
Token::Tuple { len: 16 },
|
|
|
|
seq b"1234567890123456".iter().map(|&b| Token::U8(b)),
|
|
|
|
Token::TupleEnd,
|
|
|
|
|
|
|
|
Token::U16(1234),
|
|
|
|
Token::TupleEnd,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|