@@ -842,134 +842,122 @@ make_backup = false
842
842
}
843
843
844
844
#[ test]
845
- #[ should_panic( expected = "`fn_call_width` cannot have a value that exceeds `max_width" ) ]
846
- fn test_panics_when_fn_call_width_config_exceeds_max_width ( ) {
845
+ fn test_fn_call_width_config_exceeds_max_width ( ) {
847
846
let toml = r#"
848
- max_width = 80
849
- fn_call_width = 90
847
+ max_width = 90
848
+ fn_call_width = 95
850
849
"# ;
851
- Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
850
+ let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
851
+ assert_eq ! ( config. fn_call_width( ) , 90 ) ;
852
852
}
853
853
854
854
#[ test]
855
- #[ should_panic(
856
- expected = "`attr_fn_like_width` cannot have a value that exceeds `max_width"
857
- ) ]
858
- fn test_panics_when_attr_fn_like_width_config_exceeds_max_width ( ) {
855
+ fn test_attr_fn_like_width_config_exceeds_max_width ( ) {
859
856
let toml = r#"
860
857
max_width = 80
861
858
attr_fn_like_width = 90
862
859
"# ;
863
- Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
860
+ let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
861
+ assert_eq ! ( config. attr_fn_like_width( ) , 80 ) ;
864
862
}
865
863
866
864
#[ test]
867
- #[ should_panic( expected = "`struct_lit_width` cannot have a value that exceeds `max_width" ) ]
868
- fn test_panics_when_struct_lit_config_exceeds_max_width ( ) {
865
+ fn test_struct_lit_config_exceeds_max_width ( ) {
869
866
let toml = r#"
870
- max_width = 80
867
+ max_width = 78
871
868
struct_lit_width = 90
872
869
"# ;
873
- Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
870
+ let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
871
+ assert_eq ! ( config. struct_lit_width( ) , 78 ) ;
874
872
}
875
873
876
874
#[ test]
877
- #[ should_panic(
878
- expected = "`struct_variant_width` cannot have a value that exceeds `max_width"
879
- ) ]
880
- fn test_panics_when_struct_variant_width_config_exceeds_max_width ( ) {
875
+ fn test_struct_variant_width_config_exceeds_max_width ( ) {
881
876
let toml = r#"
882
877
max_width = 80
883
878
struct_variant_width = 90
884
879
"# ;
885
- Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
880
+ let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
881
+ assert_eq ! ( config. struct_variant_width( ) , 80 ) ;
886
882
}
887
883
888
884
#[ test]
889
- #[ should_panic( expected = "`array_width` cannot have a value that exceeds `max_width" ) ]
890
- fn test_panics_when_array_width_config_exceeds_max_width ( ) {
885
+ fn test_array_width_config_exceeds_max_width ( ) {
891
886
let toml = r#"
892
- max_width = 80
893
- array_width = 90
887
+ max_width = 60
888
+ array_width = 80
894
889
"# ;
895
- Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
890
+ let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
891
+ assert_eq ! ( config. array_width( ) , 60 ) ;
896
892
}
897
893
898
894
#[ test]
899
- #[ should_panic( expected = "`chain_width` cannot have a value that exceeds `max_width" ) ]
900
- fn test_panics_when_chain_width_config_exceeds_max_width ( ) {
895
+ fn test_chain_width_config_exceeds_max_width ( ) {
901
896
let toml = r#"
902
897
max_width = 80
903
898
chain_width = 90
904
899
"# ;
905
- Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
900
+ let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
901
+ assert_eq ! ( config. chain_width( ) , 80 ) ;
906
902
}
907
903
908
904
#[ test]
909
- #[ should_panic(
910
- expected = "`single_line_if_else_max_width` cannot have a value that exceeds `max_width"
911
- ) ]
912
- fn test_panics_when_single_line_if_else_max_width_config_exceeds_max_width ( ) {
905
+ fn test_single_line_if_else_max_width_config_exceeds_max_width ( ) {
913
906
let toml = r#"
914
- max_width = 80
907
+ max_width = 70
915
908
single_line_if_else_max_width = 90
916
909
"# ;
917
- Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
910
+ let config = Config :: from_toml ( toml, Path :: new ( "" ) ) . unwrap ( ) ;
911
+ assert_eq ! ( config. single_line_if_else_max_width( ) , 70 ) ;
918
912
}
919
913
920
914
#[ test]
921
- #[ should_panic( expected = "`fn_call_width` cannot have a value that exceeds `max_width" ) ]
922
- fn test_panics_when_fn_call_width_override_exceeds_max_width ( ) {
915
+ fn test_override_fn_call_width_exceeds_max_width ( ) {
923
916
let mut config = Config :: default ( ) ;
924
917
config. override_value ( "fn_call_width" , "101" ) ;
918
+ assert_eq ! ( config. fn_call_width( ) , 100 ) ;
925
919
}
926
920
927
921
#[ test]
928
- #[ should_panic(
929
- expected = "`attr_fn_like_width` cannot have a value that exceeds `max_width"
930
- ) ]
931
- fn test_panics_when_attr_fn_like_width_override_exceeds_max_width ( ) {
922
+ fn test_override_attr_fn_like_width_exceeds_max_width ( ) {
932
923
let mut config = Config :: default ( ) ;
933
924
config. override_value ( "attr_fn_like_width" , "101" ) ;
925
+ assert_eq ! ( config. attr_fn_like_width( ) , 100 ) ;
934
926
}
935
927
936
928
#[ test]
937
- #[ should_panic( expected = "`struct_lit_width` cannot have a value that exceeds `max_width" ) ]
938
- fn test_panics_when_struct_lit_override_exceeds_max_width ( ) {
929
+ fn test_override_struct_lit_exceeds_max_width ( ) {
939
930
let mut config = Config :: default ( ) ;
940
931
config. override_value ( "struct_lit_width" , "101" ) ;
932
+ assert_eq ! ( config. struct_lit_width( ) , 100 ) ;
941
933
}
942
934
943
935
#[ test]
944
- #[ should_panic(
945
- expected = "`struct_variant_width` cannot have a value that exceeds `max_width"
946
- ) ]
947
- fn test_panics_when_struct_variant_width_override_exceeds_max_width ( ) {
936
+ fn test_override_struct_variant_width_exceeds_max_width ( ) {
948
937
let mut config = Config :: default ( ) ;
949
938
config. override_value ( "struct_variant_width" , "101" ) ;
939
+ assert_eq ! ( config. struct_variant_width( ) , 100 ) ;
950
940
}
951
941
952
942
#[ test]
953
- #[ should_panic( expected = "`array_width` cannot have a value that exceeds `max_width" ) ]
954
- fn test_panics_when_array_width_override_exceeds_max_width ( ) {
943
+ fn test_override_array_width_exceeds_max_width ( ) {
955
944
let mut config = Config :: default ( ) ;
956
945
config. override_value ( "array_width" , "101" ) ;
946
+ assert_eq ! ( config. array_width( ) , 100 ) ;
957
947
}
958
948
959
949
#[ test]
960
- #[ should_panic( expected = "`chain_width` cannot have a value that exceeds `max_width" ) ]
961
- fn test_panics_when_chain_width_override_exceeds_max_width ( ) {
950
+ fn test_override_chain_width_exceeds_max_width ( ) {
962
951
let mut config = Config :: default ( ) ;
963
952
config. override_value ( "chain_width" , "101" ) ;
953
+ assert_eq ! ( config. chain_width( ) , 100 ) ;
964
954
}
965
955
966
956
#[ test]
967
- #[ should_panic(
968
- expected = "`single_line_if_else_max_width` cannot have a value that exceeds `max_width"
969
- ) ]
970
- fn test_panics_when_single_line_if_else_max_width_override_exceeds_max_width ( ) {
957
+ fn test_override_single_line_if_else_max_width_exceeds_max_width ( ) {
971
958
let mut config = Config :: default ( ) ;
972
959
config. override_value ( "single_line_if_else_max_width" , "101" ) ;
960
+ assert_eq ! ( config. single_line_if_else_max_width( ) , 100 ) ;
973
961
}
974
962
}
975
963
}
0 commit comments