File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -4641,6 +4641,16 @@ mod tests {
46414641 assert_eq ! ( de. next( ) . unwrap( ) , DeEvent :: Eof ) ;
46424642 }
46434643
4644+ #[ test]
4645+ fn space ( ) {
4646+ let mut de = make_de ( "<tag> </tag>" ) ;
4647+ assert_eq ! ( de. next( ) . unwrap( ) , DeEvent :: Start ( BytesStart :: new( "tag" ) ) ) ;
4648+ assert_eq ! ( de. next( ) . unwrap( ) , DeEvent :: Text ( " " . into( ) ) ) ;
4649+ assert_eq ! ( de. next( ) . unwrap( ) , DeEvent :: End ( BytesEnd :: new( "tag" ) ) ) ;
4650+ assert_eq ! ( de. next( ) . unwrap( ) , DeEvent :: Eof ) ;
4651+ // Passes as expected
4652+ }
4653+
46444654 // start::text::text has no difference from start::text
46454655
46464656 #[ test]
Original file line number Diff line number Diff line change @@ -45,12 +45,32 @@ mod text {
4545 content : String ,
4646 }
4747
48- let item: Item = from_str ( r#"<root>content</root>"# ) . unwrap ( ) ;
48+ let item: Item = from_str ( r#"<root>content </root>"# ) . unwrap ( ) ;
4949
50+ // Passes as expected
5051 assert_eq ! (
5152 item,
5253 Item {
53- content: "content" . into( )
54+ content: "content " . into( )
55+ }
56+ ) ;
57+ }
58+
59+ #[ test]
60+ fn explicit_space ( ) {
61+ #[ derive( Debug , Deserialize , PartialEq ) ]
62+ struct Item {
63+ #[ serde( rename = "$text" ) ]
64+ content : String ,
65+ }
66+
67+ let item: Item = from_str ( r#"<root> </root>"# ) . unwrap ( ) ;
68+
69+ // Fails: called `Result::unwrap()` on an `Err` value: Custom("missing field `$text`")
70+ assert_eq ! (
71+ item,
72+ Item {
73+ content: " " . into( )
5474 }
5575 ) ;
5676 }
You can’t perform that action at this time.
0 commit comments