feat(impls): Add impls for std::net::Ip{,v4,v6}Addr

This commit is contained in:
Erick Tryzelaar
2016-02-21 17:02:25 -08:00
parent c03587f0bf
commit b257084f3a
4 changed files with 103 additions and 0 deletions
+16
View File
@@ -1,4 +1,5 @@
use std::collections::BTreeMap;
use std::net;
use std::path::{Path, PathBuf};
use std::str;
@@ -266,6 +267,12 @@ declare_ser_tests! {
Token::EnumMapEnd,
],
}
test_net_ipv4addr {
"1.2.3.4".parse::<net::Ipv4Addr>().unwrap() => &[Token::Str("1.2.3.4")],
}
test_net_ipv6addr {
"::1".parse::<net::Ipv6Addr>().unwrap() => &[Token::Str("::1")],
}
test_num_bigint {
BigInt::from_i64(123).unwrap() => &[Token::Str("123")],
BigInt::from_i64(-123).unwrap() => &[Token::Str("-123")],
@@ -307,6 +314,15 @@ declare_ser_tests! {
}
}
#[cfg(feature = "nightly")]
#[test]
fn test_net_ipaddr() {
assert_ser_tokens(
"1.2.3.4".parse::<net::IpAddr>().unwrap(),
&[Token::Str("1.2.3.4")],
);
}
#[test]
fn test_cannot_serialize_paths() {
let path = unsafe {