@@ -58,6 +58,14 @@ mod tests {
58
58
#[ derive( Deserialize , Serialize , SerializeHierarchy ) ]
59
59
struct TupleStruct ( bool , f32 , Inner , Outer ) ;
60
60
61
+ #[ derive( Deserialize , Serialize , SerializeHierarchy ) ]
62
+ struct NestedTupleStruct ( bool , Inner , TupleStruct ) ;
63
+
64
+ #[ derive( Deserialize , Serialize , SerializeHierarchy ) ]
65
+ struct OuterWithTupleStruct {
66
+ tuple_struct : TupleStruct ,
67
+ }
68
+
61
69
#[ test]
62
70
fn primitive_fields_are_empty ( ) {
63
71
assert_eq ! ( bool :: get_fields( ) , Default :: default ( ) ) ;
@@ -75,4 +83,55 @@ mod tests {
75
83
[ "inner" . to_string( ) , "inner.field" . to_string( ) ] . into( )
76
84
) ;
77
85
}
86
+
87
+ #[ test]
88
+ fn tuple_struct_fields_contain_fields ( ) {
89
+ assert_eq ! (
90
+ TupleStruct :: get_fields( ) ,
91
+ [ "0" , "1" , "2" , "2.field" , "3" , "3.inner" , "3.inner.field" ]
92
+ . map( |s| s. to_string( ) )
93
+ . into( )
94
+ ) ;
95
+ }
96
+
97
+ #[ test]
98
+ fn nested_tuple_struct_fields_contain_fields ( ) {
99
+ assert_eq ! (
100
+ NestedTupleStruct :: get_fields( ) ,
101
+ [
102
+ "0" ,
103
+ "1" ,
104
+ "1.field" ,
105
+ "2" ,
106
+ "2.0" ,
107
+ "2.1" ,
108
+ "2.2" ,
109
+ "2.2.field" ,
110
+ "2.3" ,
111
+ "2.3.inner" ,
112
+ "2.3.inner.field"
113
+ ]
114
+ . map( |s| s. to_string( ) )
115
+ . into( )
116
+ ) ;
117
+ }
118
+
119
+ #[ test]
120
+ fn flat_struct_contains_tuple_struct_fields ( ) {
121
+ assert_eq ! (
122
+ OuterWithTupleStruct :: get_fields( ) ,
123
+ [
124
+ "tuple_struct" ,
125
+ "tuple_struct.0" ,
126
+ "tuple_struct.1" ,
127
+ "tuple_struct.2" ,
128
+ "tuple_struct.2.field" ,
129
+ "tuple_struct.3" ,
130
+ "tuple_struct.3.inner" ,
131
+ "tuple_struct.3.inner.field"
132
+ ]
133
+ . map( |s| s. to_string( ) )
134
+ . into( )
135
+ ) ;
136
+ }
78
137
}
0 commit comments