File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -23,15 +23,31 @@ fn regress_prm(#[files("tests/data/*.[gG][sS][dD]")] gsd_file: PathBuf) {
2323 texts. keys ( ) . next ( ) . unwrap ( )
2424 } ;
2525 prm. set_prm_from_text ( & prm_ref. name , text) . unwrap ( ) ;
26+
27+ // Test that trying a wrong text doens't panic
28+ let res = prm. set_prm_from_text ( & prm_ref. name , "InvalidTextAllTheWay" ) ;
29+ assert ! ( res. is_err( ) ) ;
2630 } else {
2731 let v = match & prm_ref. constraint {
2832 gsd_parser:: PrmValueConstraint :: MinMax ( _, max) => * max,
2933 gsd_parser:: PrmValueConstraint :: Enum ( values) => * values. last ( ) . unwrap ( ) ,
3034 gsd_parser:: PrmValueConstraint :: Unconstrained => 1 ,
3135 } ;
3236 prm. set_prm ( & prm_ref. name , v) . unwrap ( ) ;
37+
38+ // Test that an invalid value results in an error rather than a panic
39+ let res = prm. set_prm ( & prm_ref. name , i64:: MIN ) ;
40+ assert ! ( res. is_err( ) ) ;
41+
42+ // Test that trying a text PRM doesn't panic
43+ let res = prm. set_prm_from_text ( & prm_ref. name , "InvalidTextAllTheWay" ) ;
44+ assert ! ( res. is_err( ) ) ;
3345 }
3446 }
3547
48+ // Test that a non-existent PRM doesn't panic
49+ let res = prm. set_prm ( "ThisPrmNeverEverExistsEver" , 0 ) ;
50+ assert ! ( res. is_err( ) ) ;
51+
3652 insta:: assert_debug_snapshot!( format!( "{}-PRM" , name) . as_ref( ) , prm. as_bytes( ) ) ;
3753}
You can’t perform that action at this time.
0 commit comments