-
Notifications
You must be signed in to change notification settings - Fork 42
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
5 changed files
with
53 additions
and
0 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
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?><exam:Foo xmlns:exam="http://example.com">1 2 3</exam:Foo> |
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,5 @@ | ||
#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] | ||
pub struct FooType(pub Vec<String>); | ||
|
||
impl Validate for FooType {} | ||
// pub type Foo = FooType; |
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,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns:tns="http://example.com" | ||
targetNamespace="http://example.com" | ||
elementFormDefault="qualified"> | ||
<xs:simpleType name="FooType"> | ||
<xs:list itemType="xs:string"/> | ||
</xs:simpleType> | ||
|
||
<xs:element name="Foo" type="tns:FooType"/> | ||
</xs:schema> |
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 super::utils; | ||
|
||
#[test] | ||
fn deserialization_works() { | ||
mod expected { | ||
use std::str::FromStr; | ||
use xsd_parser::generator::validator::Validate; | ||
|
||
use xsd_macro_utils::*; | ||
|
||
include!("expected.rs"); | ||
} | ||
|
||
let ser = include_str!("example.xml"); | ||
|
||
let de: expected::FooType = yaserde::de::from_str(ser).unwrap(); | ||
|
||
assert_eq!(de, expected::FooType(vec!["1".to_string(), "2".to_string(), "3".to_string()])); | ||
|
||
assert_eq!( | ||
r#"<?xml version="1.0" encoding="utf-8"?><FooType>1 2 3</FooType>"#, | ||
yaserde::ser::to_string(&de).unwrap() | ||
); | ||
} | ||
|
||
#[test] | ||
fn generator_does_not_panic() { | ||
println!("{}", utils::generate(include_str!("input.xsd"))) | ||
} | ||
|
||
#[test] | ||
#[ignore] // Validation is not needed in this case | ||
fn generator_output_has_correct_ast() { | ||
utils::ast_test(include_str!("input.xsd"), include_str!("expected.rs")); | ||
} |