Skip to content

Commit

Permalink
Testcase failure due to extra space in the expected result of assert_eq
Browse files Browse the repository at this point in the history
  • Loading branch information
ranraj committed May 29, 2021
1 parent 2969839 commit 9a126bf
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions xml_schema_derive/src/xsd/attribute.rs
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
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
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
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
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
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

0 comments on commit 9a126bf

Please sign in to comment.