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, BTreeSet, HashMap, HashSet};
use std::net;
use std::path::PathBuf;
use num::FromPrimitive;
@@ -571,6 +572,12 @@ declare_tests! {
Token::Unit,
],
}
test_net_ipv4addr {
"1.2.3.4".parse::<net::Ipv4Addr>().unwrap() => vec![Token::Str("1.2.3.4")],
}
test_net_ipv6addr {
"::1".parse::<net::Ipv6Addr>().unwrap() => vec![Token::Str("::1")],
}
test_num_bigint {
BigInt::from_i64(123).unwrap() => vec![Token::Str("123")],
BigInt::from_i64(-123).unwrap() => vec![Token::Str("-123")],
@@ -607,6 +614,15 @@ declare_tests! {
}
}
#[cfg(feature = "nightly")]
#[test]
fn test_net_ipaddr() {
assert_de_tokens(
"1.2.3.4".parse::<net::IpAddr>().unwrap(),
vec![Token::Str("1.2.3.4")],
);
}
#[test]
fn test_enum_error() {
assert_de_tokens_error::<Enum>(