File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -150,3 +150,39 @@ impl<ID: IDLike> IDCollection<ID> for HashSet<ID> {
150150impl < ID : IDLike > IDCollection < ID > for IndexSet < ID > {
151151 define_id_methods ! ( ) ;
152152}
153+
154+ #[ cfg( test) ]
155+ mod tests {
156+ use super :: * ;
157+ use rstest:: rstest;
158+
159+ use serde:: Deserialize ;
160+
161+ #[ derive( Debug , Deserialize ) ]
162+ struct Record {
163+ id : GenericID ,
164+ }
165+
166+ fn deserialise_id ( id : & str ) -> Result < Record > {
167+ Ok ( toml:: from_str ( & format ! ( "id = \" {id}\" " ) ) ?)
168+ }
169+
170+ #[ rstest]
171+ #[ case( "commodity1" ) ]
172+ #[ case( "some commodity" ) ]
173+ #[ case( "PROCESS" ) ]
174+ #[ case( "café" ) ] // unicode supported
175+ fn test_deserialise_id_valid ( #[ case] id : & str ) {
176+ assert_eq ! ( deserialise_id( id) . unwrap( ) . id. to_string( ) , id) ;
177+ }
178+
179+ #[ rstest]
180+ #[ case( "" ) ]
181+ #[ case( "all" ) ]
182+ #[ case( "annual" ) ]
183+ #[ case( "ALL" ) ]
184+ #[ case( " ALL " ) ]
185+ fn test_deserialise_id_invalid ( #[ case] id : & str ) {
186+ assert ! ( deserialise_id( id) . is_err( ) ) ;
187+ }
188+ }
You can’t perform that action at this time.
0 commit comments