-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::common_macro::schema_imports::*; | ||
|
||
#[cfg(feature = "std")] | ||
use std::net::IpAddr; | ||
|
||
#[test] | ||
fn ip_addr_schema() { | ||
let actual_name = IpAddr::declaration(); | ||
let mut actual_defs = schema_map!(); | ||
IpAddr::add_definitions_recursively(&mut actual_defs); | ||
|
||
assert_eq!("IpAddr", actual_name); | ||
assert_eq!( | ||
schema_map! { | ||
"IpAddr" => Definition::Union { | ||
variants: vec![ | ||
"IpAddr::V4".to_string(), | ||
"IpAddr::V6".to_string() | ||
], | ||
}, | ||
"IpAddr::V4" => Definition::Tuple { | ||
elements: vec!["u8".to_string(), "u8".to_string(), "u8".to_string(), "u8".to_string()], | ||
}, | ||
"IpAddr::V6" => Definition::Tuple { | ||
elements: vec![ | ||
"u16".to_string(), "u16".to_string(), "u16".to_string(), "u16".to_string(), | ||
"u16".to_string(), "u16".to_string(), "u16".to_string(), "u16".to_string(), | ||
], | ||
}, | ||
"u8" => Definition::Primitive(1), | ||
"u16" => Definition::Primitive(2), | ||
}, | ||
actual_defs | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters