diff --git a/xsd-parser/tests/mod.rs b/xsd-parser/tests/mod.rs index e3e37b83..ba4a1fa7 100644 --- a/xsd-parser/tests/mod.rs +++ b/xsd-parser/tests/mod.rs @@ -16,6 +16,7 @@ mod simple_type; mod tuple_with_integer; mod tuple_with_string; mod tuple_with_vec_int; +mod tuple_with_vec_string; mod type_name_clash; mod union; mod xsd_string; diff --git a/xsd-parser/tests/tuple_with_vec_string/example.xml b/xsd-parser/tests/tuple_with_vec_string/example.xml new file mode 100644 index 00000000..b907b02e --- /dev/null +++ b/xsd-parser/tests/tuple_with_vec_string/example.xml @@ -0,0 +1 @@ +1 2 3 diff --git a/xsd-parser/tests/tuple_with_vec_string/expected.rs b/xsd-parser/tests/tuple_with_vec_string/expected.rs new file mode 100644 index 00000000..82f0579c --- /dev/null +++ b/xsd-parser/tests/tuple_with_vec_string/expected.rs @@ -0,0 +1,5 @@ +#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)] +pub struct FooType(pub Vec); + +impl Validate for FooType {} +// pub type Foo = FooType; diff --git a/xsd-parser/tests/tuple_with_vec_string/input.xsd b/xsd-parser/tests/tuple_with_vec_string/input.xsd new file mode 100644 index 00000000..07f41ff3 --- /dev/null +++ b/xsd-parser/tests/tuple_with_vec_string/input.xsd @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/xsd-parser/tests/tuple_with_vec_string/mod.rs b/xsd-parser/tests/tuple_with_vec_string/mod.rs new file mode 100644 index 00000000..5cdf26bc --- /dev/null +++ b/xsd-parser/tests/tuple_with_vec_string/mod.rs @@ -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#"1 2 3"#, + 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")); +}