From 9a126bf003f82978a25c51793b1322ae7d779799 Mon Sep 17 00:00:00 2001 From: "ranjithraj.d" Date: Sat, 29 May 2021 19:43:43 +0530 Subject: [PATCH] Testcase failure due to extra space in the expected result of assert_eq --- xml_schema_derive/src/xsd/attribute.rs | 8 ++++---- xml_schema_derive/src/xsd/element.rs | 8 ++++---- xml_schema_derive/src/xsd/extension.rs | 4 ++-- xml_schema_derive/src/xsd/list.rs | 2 +- xml_schema_derive/src/xsd/schema.rs | 2 +- xml_schema_derive/src/xsd/simple_type.rs | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/xml_schema_derive/src/xsd/attribute.rs b/xml_schema_derive/src/xsd/attribute.rs index 5308ff7..b914272 100644 --- a/xml_schema_derive/src/xsd/attribute.rs +++ b/xml_schema_derive/src/xsd/attribute.rs @@ -125,7 +125,7 @@ mod tests { ); assert_eq!( implementation, - r#"# [ yaserde ( attribute ) ] pub language : String ,"# + r#"# [yaserde (attribute)] pub language : String ,"# ); } @@ -149,7 +149,7 @@ mod tests { ); assert_eq!( implementation, - r#"# [ yaserde ( attribute ) ] pub language : Option < String > ,"# + r#"# [yaserde (attribute)] pub language : Option < String > ,"# ); } @@ -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 > ,"# ); } @@ -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 > ,"# ); } diff --git a/xml_schema_derive/src/xsd/element.rs b/xml_schema_derive/src/xsd/element.rs index afd53b3..2f58757 100644 --- a/xml_schema_derive/src/xsd/element.rs +++ b/xml_schema_derive/src/xsd/element.rs @@ -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() { @@ -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 ) ); @@ -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 ) ); diff --git a/xml_schema_derive/src/xsd/extension.rs b/xml_schema_derive/src/xsd/extension.rs index 0e4db29..1b78edf 100644 --- a/xml_schema_derive/src/xsd/extension.rs +++ b/xml_schema_derive/src/xsd/extension.rs @@ -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] @@ -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 > ,"); } } diff --git a/xml_schema_derive/src/xsd/list.rs b/xml_schema_derive/src/xsd/list.rs index dee7e08..369d43a 100644 --- a/xml_schema_derive/src/xsd/list.rs +++ b/xml_schema_derive/src/xsd/list.rs @@ -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)) } }"# ); } } diff --git a/xml_schema_derive/src/xsd/schema.rs b/xml_schema_derive/src/xsd/schema.rs index 6a9d6d3..825ed79 100644 --- a/xml_schema_derive/src/xsd/schema.rs +++ b/xml_schema_derive/src/xsd/schema.rs @@ -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")]"# ); } } diff --git a/xml_schema_derive/src/xsd/simple_type.rs b/xml_schema_derive/src/xsd/simple_type.rs index 7cae817..baf30aa 100644 --- a/xml_schema_derive/src/xsd/simple_type.rs +++ b/xml_schema_derive/src/xsd/simple_type.rs @@ -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() { @@ -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