diff --git a/xsd-parser/tests/any/expected.rs b/xsd-parser/tests/any/expected.rs
index f568b7ff..917fe12f 100644
--- a/xsd-parser/tests/any/expected.rs
+++ b/xsd-parser/tests/any/expected.rs
@@ -4,3 +4,6 @@ pub struct FooType {
#[yaserde(prefix = "tns", rename = "Name")]
pub name: String,
}
+
+impl Validate for FooType {}
+// pub type Foo = FooType;
diff --git a/xsd-parser/tests/any/mod.rs b/xsd-parser/tests/any/mod.rs
index e151f6e8..2135641e 100644
--- a/xsd-parser/tests/any/mod.rs
+++ b/xsd-parser/tests/any/mod.rs
@@ -3,6 +3,7 @@ use super::utils;
#[test]
fn deserialization_works() {
mod expected {
+ use xsd_parser::generator::validator::Validate;
use yaserde_derive::{YaDeserialize, YaSerialize};
include!("expected.rs");
@@ -21,7 +22,6 @@ fn generator_does_not_panic() {
}
#[test]
-#[ignore]
fn generator_output_has_correct_ast() {
utils::ast_test(include_str!("input.xsd"), include_str!("expected.rs"));
}
diff --git a/xsd-parser/tests/choice/expected.rs b/xsd-parser/tests/choice/expected.rs
index 325a8d7f..52c1f6ae 100644
--- a/xsd-parser/tests/choice/expected.rs
+++ b/xsd-parser/tests/choice/expected.rs
@@ -1,9 +1,13 @@
#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]
pub struct BarType(pub String);
+impl Validate for BarType {}
+
#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]
pub struct BazType(pub i32);
+impl Validate for BazType {}
+
#[derive(PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "tns", namespace = "tns: http://example.com")]
pub enum FooTypeChoice {
@@ -18,9 +22,14 @@ impl Default for FooTypeChoice {
}
}
+impl Validate for FooTypeChoice {}
+
#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
#[yaserde(prefix = "tns", namespace = "tns: http://example.com")]
pub struct FooType {
#[yaserde(flatten)]
pub foo_type_choice: FooTypeChoice,
}
+
+impl Validate for FooType {}
+// pub type Foo = FooType;
diff --git a/xsd-parser/tests/choice/mod.rs b/xsd-parser/tests/choice/mod.rs
index 9e307a65..4ff1888b 100644
--- a/xsd-parser/tests/choice/mod.rs
+++ b/xsd-parser/tests/choice/mod.rs
@@ -6,6 +6,7 @@ fn deserialization_works() {
use std::str::FromStr;
use xsd_macro_utils::*;
+ use xsd_parser::generator::validator::Validate;
use yaserde_derive::{YaDeserialize, YaSerialize};
include!("expected.rs");
@@ -27,7 +28,6 @@ fn generator_does_not_panic() {
}
#[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"));
}
diff --git a/xsd-parser/tests/mod.rs b/xsd-parser/tests/mod.rs
index 0b33f849..bead4221 100644
--- a/xsd-parser/tests/mod.rs
+++ b/xsd-parser/tests/mod.rs
@@ -14,8 +14,8 @@ mod rename_only_where_needed;
mod restriction_any_type;
mod simple_type;
mod tuple_with_integer;
-mod tuple_with_string;
-mod tuple_with_vec;
+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/simple_type/expected.rs b/xsd-parser/tests/simple_type/expected.rs
index a67851b5..7b16aa3f 100644
--- a/xsd-parser/tests/simple_type/expected.rs
+++ b/xsd-parser/tests/simple_type/expected.rs
@@ -1,2 +1,5 @@
#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]
-pub struct FooType (pub String);
+pub struct FooType(pub String);
+
+impl Validate for FooType {}
+// pub type Foo = FooType;
diff --git a/xsd-parser/tests/simple_type/mod.rs b/xsd-parser/tests/simple_type/mod.rs
index a4843eeb..63bef91a 100644
--- a/xsd-parser/tests/simple_type/mod.rs
+++ b/xsd-parser/tests/simple_type/mod.rs
@@ -4,12 +4,8 @@ use super::utils;
fn deserialization_works() {
mod expected {
use std::str::FromStr;
-
use xsd_macro_utils::*;
-
- trait Validate {
- fn validate(&self) -> Result<(), String>;
- }
+ use xsd_parser::generator::validator::Validate;
include!("expected.rs");
}
@@ -27,7 +23,6 @@ fn generator_does_not_panic() {
}
#[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"));
}
diff --git a/xsd-parser/tests/tuple_with_integer/expected.rs b/xsd-parser/tests/tuple_with_integer/expected.rs
index 2e78b1cf..0347b2fa 100644
--- a/xsd-parser/tests/tuple_with_integer/expected.rs
+++ b/xsd-parser/tests/tuple_with_integer/expected.rs
@@ -1,2 +1,5 @@
#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]
-pub struct FooType (pub Integer);
+pub struct FooType(pub xs::Integer);
+
+impl Validate for FooType {}
+// pub type Foo = FooType;
diff --git a/xsd-parser/tests/tuple_with_integer/mod.rs b/xsd-parser/tests/tuple_with_integer/mod.rs
index 7a88f83f..d12f2c8a 100644
--- a/xsd-parser/tests/tuple_with_integer/mod.rs
+++ b/xsd-parser/tests/tuple_with_integer/mod.rs
@@ -7,9 +7,10 @@ use super::utils;
fn deserialization_works() {
mod expected {
use std::str::FromStr;
+ use xsd_parser::generator::validator::Validate;
use xsd_macro_utils::*;
- use xsd_types::types::Integer;
+ use xsd_types::types as xs;
include!("expected.rs");
}
@@ -27,7 +28,6 @@ fn generator_does_not_panic() {
}
#[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"));
}
diff --git a/xsd-parser/tests/tuple_with_string/example.xml b/xsd-parser/tests/tuple_with_string/example.xml
deleted file mode 100644
index d8fb5a0b..00000000
--- a/xsd-parser/tests/tuple_with_string/example.xml
+++ /dev/null
@@ -1 +0,0 @@
-abc
diff --git a/xsd-parser/tests/tuple_with_string/example_empty.xml b/xsd-parser/tests/tuple_with_string/example_empty.xml
deleted file mode 100644
index 9a9174d3..00000000
--- a/xsd-parser/tests/tuple_with_string/example_empty.xml
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/xsd-parser/tests/tuple_with_string/expected.rs b/xsd-parser/tests/tuple_with_string/expected.rs
deleted file mode 100644
index ef82ccf1..00000000
--- a/xsd-parser/tests/tuple_with_string/expected.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]
-pub struct FooType(pub String);
diff --git a/xsd-parser/tests/tuple_with_string/mod.rs b/xsd-parser/tests/tuple_with_string/mod.rs
deleted file mode 100644
index ef829ba2..00000000
--- a/xsd-parser/tests/tuple_with_string/mod.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-use super::utils;
-
-#[test]
-fn deserialization_works() {
- mod expected {
- use std::str::FromStr;
-
- 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("abc".to_string()));
- }
-
- {
- // Empty element should be deserialized into an empty string
- let ser = include_str!("example_empty.xml");
-
- let de: expected::FooType = yaserde::de::from_str(ser).unwrap();
-
- assert_eq!(de, expected::FooType("".to_string()));
- }
-}
-
-#[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"));
-}
diff --git a/xsd-parser/tests/tuple_with_vec/example.xml b/xsd-parser/tests/tuple_with_vec_int/example.xml
similarity index 100%
rename from xsd-parser/tests/tuple_with_vec/example.xml
rename to xsd-parser/tests/tuple_with_vec_int/example.xml
diff --git a/xsd-parser/tests/tuple_with_vec/expected.rs b/xsd-parser/tests/tuple_with_vec_int/expected.rs
similarity index 64%
rename from xsd-parser/tests/tuple_with_vec/expected.rs
rename to xsd-parser/tests/tuple_with_vec_int/expected.rs
index d7968913..356541fc 100644
--- a/xsd-parser/tests/tuple_with_vec/expected.rs
+++ b/xsd-parser/tests/tuple_with_vec_int/expected.rs
@@ -1,2 +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_string/input.xsd b/xsd-parser/tests/tuple_with_vec_int/input.xsd
similarity index 88%
rename from xsd-parser/tests/tuple_with_string/input.xsd
rename to xsd-parser/tests/tuple_with_vec_int/input.xsd
index 1bbb4046..2b757d35 100644
--- a/xsd-parser/tests/tuple_with_string/input.xsd
+++ b/xsd-parser/tests/tuple_with_vec_int/input.xsd
@@ -4,7 +4,7 @@
targetNamespace="http://example.com"
elementFormDefault="qualified">
-
+
diff --git a/xsd-parser/tests/tuple_with_vec/mod.rs b/xsd-parser/tests/tuple_with_vec_int/mod.rs
similarity index 92%
rename from xsd-parser/tests/tuple_with_vec/mod.rs
rename to xsd-parser/tests/tuple_with_vec_int/mod.rs
index 86f41c4f..cb335e3e 100644
--- a/xsd-parser/tests/tuple_with_vec/mod.rs
+++ b/xsd-parser/tests/tuple_with_vec_int/mod.rs
@@ -4,6 +4,7 @@ use super::utils;
fn deserialization_works() {
mod expected {
use std::str::FromStr;
+ use xsd_parser::generator::validator::Validate;
use xsd_macro_utils::*;
@@ -28,7 +29,6 @@ fn generator_does_not_panic() {
}
#[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"));
}
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/input.xsd b/xsd-parser/tests/tuple_with_vec_string/input.xsd
similarity index 100%
rename from xsd-parser/tests/tuple_with_vec/input.xsd
rename to xsd-parser/tests/tuple_with_vec_string/input.xsd
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..512b7f2b
--- /dev/null
+++ b/xsd-parser/tests/tuple_with_vec_string/mod.rs
@@ -0,0 +1,34 @@
+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]
+fn generator_output_has_correct_ast() {
+ utils::ast_test(include_str!("input.xsd"), include_str!("expected.rs"));
+}