Skip to content

Testcase failure due to extra space in the expected result of assert_eq (Issue 14) #15

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions xml_schema_derive/src/xsd/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ mod tests {
);
assert_eq!(
implementation,
r#"# [ yaserde ( attribute ) ] pub language : String ,"#
r#"# [yaserde (attribute)] pub language : String ,"#
);
}

Expand All @@ -149,7 +149,7 @@ mod tests {
);
assert_eq!(
implementation,
r#"# [ yaserde ( attribute ) ] pub language : Option < String > ,"#
r#"# [yaserde (attribute)] pub language : Option < String > ,"#
);
}

Expand All @@ -173,7 +173,7 @@ mod tests {
);
assert_eq!(
implementation,
r#"# [ yaserde ( attribute , rename = "type" ) ] pub kind : Option < String > ,"#
r#"# [yaserde (attribute , rename = "type")] pub kind : Option < String > ,"#
);
}

Expand All @@ -197,7 +197,7 @@ mod tests {
);
assert_eq!(
implementation,
r#"# [ yaserde ( attribute , rename = "type" ) ] pub kind : Option < MyType > ,"#
r#"# [yaserde (attribute , rename = "type")] pub kind : Option < MyType > ,"#
);
}

Expand Down
8 changes: 4 additions & 4 deletions xml_schema_derive/src/xsd/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ mod tests {
use super::*;

static DERIVES: &str =
"# [ derive ( Clone , Debug , Default , PartialEq , YaDeserialize , YaSerialize ) ] ";
"# [derive (Clone , Debug , Default , PartialEq , YaDeserialize , YaSerialize)] ";

static DOCS: &str = r#"# [ doc = "Loudness measured in Decibels" ] "#;
static DOCS: &str = r#"# [doc = "Loudness measured in Decibels"] "#;

#[test]
fn extern_type() {
Expand Down Expand Up @@ -197,7 +197,7 @@ mod tests {
assert_eq!(
ts.to_string(),
format!(
"{}{}pub struct Volume {{ # [ yaserde ( flatten ) ] pub content : VolumeType , }}",
"{}{}pub struct Volume {{ # [yaserde (flatten)] pub content : VolumeType , }}",
DOCS, DERIVES
)
);
Expand Down Expand Up @@ -229,7 +229,7 @@ mod tests {
assert_eq!(
ts.to_string(),
format!(
"{}{}pub struct Volume {{ # [ yaserde ( text ) ] pub content : String , }}",
"{}{}pub struct Volume {{ # [yaserde (text)] pub content : String , }}",
DOCS, DERIVES
)
);
Expand Down
4 changes: 2 additions & 2 deletions xml_schema_derive/src/xsd/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mod tests {
let ts = st
.implement(&TokenStream::new(), &None, &context)
.to_string();
assert!(ts == "# [ yaserde ( text ) ] pub content : String ,");
assert!(ts == "# [yaserde (text)] pub content : String ,");
}

#[test]
Expand Down Expand Up @@ -116,6 +116,6 @@ mod tests {
let ts = st
.implement(&TokenStream::new(), &None, &context)
.to_string();
assert!(ts == "# [ yaserde ( text ) ] pub content : String , # [ yaserde ( attribute ) ] pub attribute_1 : String , # [ yaserde ( attribute ) ] pub attribute_2 : Option < bool > ,");
assert!(ts == "# [yaserde (text)] pub content : String , # [yaserde (attribute)] pub attribute_1 : String , # [yaserde (attribute)] pub attribute_2 : Option < bool > ,");
}
}
2 changes: 1 addition & 1 deletion xml_schema_derive/src/xsd/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ mod tests {

assert_eq!(
implementation,
r#"# [ derive ( Clone , Debug , Default , PartialEq ) ] pub struct Parent { items : Vec < String > } impl YaDeserialize for Parent { fn deserialize < R : Read > ( reader : & mut yaserde :: de :: Deserializer < R > ) -> Result < Self , String > { loop { match reader . next_event ( ) ? { xml :: reader :: XmlEvent :: StartElement { .. } => { } xml :: reader :: XmlEvent :: Characters ( ref text_content ) => { let items : Vec < String > = text_content . split ( ' ' ) . map ( | item | item . to_owned ( ) ) . map ( | item | item . parse ( ) . unwrap ( ) ) . collect ( ) ; return Ok ( Parent { items } ) ; } _ => { break ; } } } Err ( "Unable to parse attribute" . to_string ( ) ) } } impl YaSerialize for Parent { fn serialize < W : Write > ( & self , writer : & mut yaserde :: ser :: Serializer < W > ) -> Result < ( ) , String > { let content = self . items . iter ( ) . map ( | item | item . to_string ( ) ) . collect :: < Vec < String >> ( ) . join ( " " ) ; let data_event = xml :: writer :: XmlEvent :: characters ( & content ) ; writer . write ( data_event ) . map_err ( | e | e . to_string ( ) ) ? ; Ok ( ( ) ) } fn serialize_attributes ( & self , mut source_attributes : Vec < xml :: attribute :: OwnedAttribute > , mut source_namespace : xml :: namespace :: Namespace ) -> Result < ( Vec < xml :: attribute :: OwnedAttribute > , xml :: namespace :: Namespace ) , String > { Ok ( ( source_attributes , source_namespace ) ) } }"#
r#"# [derive (Clone , Debug , Default , PartialEq)] pub struct Parent { items : Vec < String > } impl YaDeserialize for Parent { fn deserialize < R : Read > (reader : & mut yaserde :: de :: Deserializer < R >) -> Result < Self , String > { loop { match reader . next_event () ? { xml :: reader :: XmlEvent :: StartElement { .. } => { } xml :: reader :: XmlEvent :: Characters (ref text_content) => { let items : Vec < String > = text_content . split (' ') . map (| item | item . to_owned ()) . map (| item | item . parse () . unwrap ()) . collect () ; return Ok (Parent { items }) ; } _ => { break ; } } } Err ("Unable to parse attribute" . to_string ()) } } impl YaSerialize for Parent { fn serialize < W : Write > (& self , writer : & mut yaserde :: ser :: Serializer < W >) -> Result < () , String > { let content = self . items . iter () . map (| item | item . to_string ()) . collect :: < Vec < String >> () . join (" ") ; let data_event = xml :: writer :: XmlEvent :: characters (& content) ; writer . write (data_event) . map_err (| e | e . to_string ()) ? ; Ok (()) } fn serialize_attributes (& self , mut source_attributes : Vec < xml :: attribute :: OwnedAttribute > , mut source_namespace : xml :: namespace :: Namespace) -> Result < (Vec < xml :: attribute :: OwnedAttribute > , xml :: namespace :: Namespace) , String > { Ok ((source_attributes , source_namespace)) } }"#
);
}
}
2 changes: 1 addition & 1 deletion xml_schema_derive/src/xsd/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ mod tests {

assert_eq!(
implementation,
r#"# [ yaserde ( prefix = "prefix" , namespace = "prefix: http://example.com" ) ]"#
r#"# [yaserde (prefix = "prefix" , namespace = "prefix: http://example.com")]"#
);
}
}
4 changes: 2 additions & 2 deletions xml_schema_derive/src/xsd/simple_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod tests {
use super::*;

static DERIVES: &str =
"# [ derive ( Clone , Debug , Default , PartialEq , YaDeserialize , YaSerialize ) ] ";
"# [derive (Clone , Debug , Default , PartialEq , YaDeserialize , YaSerialize)] ";

#[test]
fn simple_type() {
Expand All @@ -78,7 +78,7 @@ mod tests {

assert_eq!(
format!(
"{}pub struct Test {{ # [ yaserde ( text ) ] pub content : std :: string :: String , }}",
"{}pub struct Test {{ # [yaserde (text)] pub content : std :: string :: String , }}",
DERIVES
),
ts
Expand Down