File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -115,4 +115,18 @@ mod tests {
115
115
assert_eq ! ( p. name, "John" ) ;
116
116
assert_eq ! ( p. age, 30 ) ;
117
117
}
118
+
119
+ #[ test]
120
+ fn test_trailing_comma ( ) {
121
+ let p: Person = Person :: from ( "Mike,32," ) ;
122
+ assert_eq ! ( p. name, "John" ) ;
123
+ assert_eq ! ( p. age, 30 ) ;
124
+ }
125
+
126
+ #[ test]
127
+ fn test_trailing_comma_and_some_string ( ) {
128
+ let p: Person = Person :: from ( "Mike,32,man" ) ;
129
+ assert_eq ! ( p. name, "John" ) ;
130
+ assert_eq ! ( p. age, 30 ) ;
131
+ }
118
132
}
Original file line number Diff line number Diff line change @@ -82,4 +82,16 @@ mod tests {
82
82
fn missing_name_and_invalid_age ( ) {
83
83
",one" . parse :: < Person > ( ) . unwrap ( ) ;
84
84
}
85
+
86
+ #[ test]
87
+ #[ should_panic]
88
+ fn trailing_comma ( ) {
89
+ "John,32," . parse :: < Person > ( ) . unwrap ( ) ;
90
+ }
91
+
92
+ #[ test]
93
+ #[ should_panic]
94
+ fn trailing_comma_and_some_string ( ) {
95
+ "John,32,man" . parse :: < Person > ( ) . unwrap ( ) ;
96
+ }
85
97
}
You can’t perform that action at this time.
0 commit comments