@@ -802,6 +802,15 @@ mod fixed_name {
802
802
use super :: * ;
803
803
use pretty_assertions:: assert_eq;
804
804
805
+ #[ derive( Debug , Deserialize , PartialEq ) ]
806
+ struct List {
807
+ /// Outer list mapped to elements, inner -- to `xs:list`.
808
+ ///
809
+ /// `#[serde(default)]` is not required, because correct
810
+ /// XML will always contains at least 1 element.
811
+ item : [ Vec < String > ; 1 ] ,
812
+ }
813
+
805
814
/// Special case: zero elements
806
815
#[ test]
807
816
fn zero ( ) {
@@ -832,15 +841,6 @@ mod fixed_name {
832
841
/// Special case: one element
833
842
#[ test]
834
843
fn one ( ) {
835
- #[ derive( Debug , Deserialize , PartialEq ) ]
836
- struct List {
837
- /// Outer list mapped to elements, inner -- to `xs:list`.
838
- ///
839
- /// `#[serde(default)]` is not required, because correct
840
- /// XML will always contains at least 1 element.
841
- item : [ Vec < String > ; 1 ] ,
842
- }
843
-
844
844
let data: List = from_str (
845
845
r#"
846
846
<root>
@@ -858,6 +858,21 @@ mod fixed_name {
858
858
) ;
859
859
}
860
860
861
+ /// Special case: empty `xs:list`
862
+ #[ test]
863
+ fn empty ( ) {
864
+ let data: List = from_str (
865
+ r#"
866
+ <root>
867
+ <item/>
868
+ </root>
869
+ "# ,
870
+ )
871
+ . unwrap ( ) ;
872
+
873
+ assert_eq ! ( data, List { item: [ vec![ ] ] } ) ;
874
+ }
875
+
861
876
/// Special case: outer list is always mapped to an elements sequence,
862
877
/// not to an `xs:list`
863
878
#[ test]
@@ -1669,6 +1684,21 @@ mod fixed_name {
1669
1684
) ;
1670
1685
}
1671
1686
1687
+ /// Special case: empty `xs:list`
1688
+ #[ test]
1689
+ fn empty ( ) {
1690
+ let data: List = from_str (
1691
+ r#"
1692
+ <root>
1693
+ <item/>
1694
+ </root>
1695
+ "# ,
1696
+ )
1697
+ . unwrap ( ) ;
1698
+
1699
+ assert_eq ! ( data, List { item: vec![ vec![ ] ] } ) ;
1700
+ }
1701
+
1672
1702
/// Special case: outer list is always mapped to an elements sequence,
1673
1703
/// not to an `xs:list`
1674
1704
#[ test]
@@ -2866,6 +2896,16 @@ mod variable_name {
2866
2896
use super :: * ;
2867
2897
use pretty_assertions:: assert_eq;
2868
2898
2899
+ #[ derive( Debug , Deserialize , PartialEq ) ]
2900
+ struct List {
2901
+ /// Outer list mapped to elements, inner -- to `xs:list`.
2902
+ ///
2903
+ /// `#[serde(default)]` is not required, because correct
2904
+ /// XML will always contains at least 1 element.
2905
+ #[ serde( rename = "$value" ) ]
2906
+ element : [ Vec < String > ; 1 ] ,
2907
+ }
2908
+
2869
2909
/// Special case: zero elements
2870
2910
#[ test]
2871
2911
fn zero ( ) {
@@ -2897,16 +2937,6 @@ mod variable_name {
2897
2937
/// Special case: one element
2898
2938
#[ test]
2899
2939
fn one ( ) {
2900
- #[ derive( Debug , Deserialize , PartialEq ) ]
2901
- struct List {
2902
- /// Outer list mapped to elements, inner -- to `xs:list`.
2903
- ///
2904
- /// `#[serde(default)]` is not required, because correct
2905
- /// XML will always contains at least 1 element.
2906
- #[ serde( rename = "$value" ) ]
2907
- element : [ Vec < String > ; 1 ] ,
2908
- }
2909
-
2910
2940
let data: List = from_str (
2911
2941
r#"
2912
2942
<root>
@@ -2924,6 +2954,21 @@ mod variable_name {
2924
2954
) ;
2925
2955
}
2926
2956
2957
+ /// Special case: empty `xs:list`
2958
+ #[ test]
2959
+ fn empty ( ) {
2960
+ let data: List = from_str (
2961
+ r#"
2962
+ <root>
2963
+ <item/>
2964
+ </root>
2965
+ "# ,
2966
+ )
2967
+ . unwrap ( ) ;
2968
+
2969
+ assert_eq ! ( data, List { element: [ vec![ ] ] } ) ;
2970
+ }
2971
+
2927
2972
/// Special case: outer list is always mapped to an elements sequence,
2928
2973
/// not to an `xs:list`
2929
2974
#[ test]
@@ -4008,6 +4053,26 @@ mod variable_name {
4008
4053
) ;
4009
4054
}
4010
4055
4056
+ /// Special case: empty `xs:list`
4057
+ #[ test]
4058
+ fn empty ( ) {
4059
+ let data: List = from_str (
4060
+ r#"
4061
+ <root>
4062
+ <item/>
4063
+ </root>
4064
+ "# ,
4065
+ )
4066
+ . unwrap ( ) ;
4067
+
4068
+ assert_eq ! (
4069
+ data,
4070
+ List {
4071
+ element: vec![ vec![ ] ]
4072
+ }
4073
+ ) ;
4074
+ }
4075
+
4011
4076
/// Special case: outer list is always mapped to an elements sequence,
4012
4077
/// not to an `xs:list`
4013
4078
#[ test]
0 commit comments