Skip to content

Fix and re-enable some ignored tests #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
3 changes: 3 additions & 0 deletions xsd-parser/tests/any/expected.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ pub struct FooType {
#[yaserde(prefix = "tns", rename = "Name")]
pub name: String,
}

impl Validate for FooType {}
// pub type Foo = FooType;
2 changes: 1 addition & 1 deletion xsd-parser/tests/any/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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"));
}
9 changes: 9 additions & 0 deletions xsd-parser/tests/choice/expected.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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;
2 changes: 1 addition & 1 deletion xsd-parser/tests/choice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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"));
}
4 changes: 2 additions & 2 deletions xsd-parser/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
5 changes: 4 additions & 1 deletion xsd-parser/tests/simple_type/expected.rs
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 1 addition & 6 deletions xsd-parser/tests/simple_type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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"));
}
5 changes: 4 additions & 1 deletion xsd-parser/tests/tuple_with_integer/expected.rs
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions xsd-parser/tests/tuple_with_integer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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"));
}
1 change: 0 additions & 1 deletion xsd-parser/tests/tuple_with_string/example.xml

This file was deleted.

1 change: 0 additions & 1 deletion xsd-parser/tests/tuple_with_string/example_empty.xml

This file was deleted.

2 changes: 0 additions & 2 deletions xsd-parser/tests/tuple_with_string/expected.rs

This file was deleted.

40 changes: 0 additions & 40 deletions xsd-parser/tests/tuple_with_string/mod.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
#[derive(Default, PartialEq, Debug, UtilsTupleIo, UtilsDefaultSerde)]
pub struct FooType(pub Vec<i32>);

impl Validate for FooType {}
// pub type Foo = FooType;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
targetNamespace="http://example.com"
elementFormDefault="qualified">
<xs:simpleType name="FooType">
<xs:restriction base="xs:string"/>
<xs:list itemType="xs:int"/>
</xs:simpleType>

<xs:element name="Foo" type="tns:FooType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand All @@ -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"));
}
1 change: 1 addition & 0 deletions xsd-parser/tests/tuple_with_vec_string/example.xml
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>
5 changes: 5 additions & 0 deletions xsd-parser/tests/tuple_with_vec_string/expected.rs
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;
34 changes: 34 additions & 0 deletions xsd-parser/tests/tuple_with_vec_string/mod.rs
Original file line number Diff line number Diff line change
@@ -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#"<?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]
fn generator_output_has_correct_ast() {
utils::ast_test(include_str!("input.xsd"), include_str!("expected.rs"));
}