Skip to content

Commit d8ae6a9

Browse files
tests: add a few for style edition config defaults
1 parent a23d3cc commit d8ae6a9

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

src/config/mod.rs

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,113 @@ make_backup = false
712712
assert_eq!(&toml, &default_config);
713713
}
714714

715+
#[test]
716+
fn test_dump_style_edition_2024_config() {
717+
let edition_2024_config = format!(
718+
r#"max_width = 100
719+
hard_tabs = false
720+
tab_spaces = 4
721+
newline_style = "Auto"
722+
indent_style = "Block"
723+
use_small_heuristics = "Default"
724+
fn_call_width = 60
725+
attr_fn_like_width = 70
726+
struct_lit_width = 18
727+
struct_variant_width = 35
728+
array_width = 60
729+
chain_width = 60
730+
single_line_if_else_max_width = 50
731+
single_line_let_else_max_width = 50
732+
wrap_comments = false
733+
format_code_in_doc_comments = false
734+
doc_comment_code_block_width = 100
735+
comment_width = 80
736+
normalize_comments = false
737+
normalize_doc_attributes = false
738+
format_strings = false
739+
format_macro_matchers = false
740+
format_macro_bodies = true
741+
skip_macro_invocations = []
742+
hex_literal_case = "Preserve"
743+
empty_item_single_line = true
744+
struct_lit_single_line = true
745+
fn_single_line = false
746+
where_single_line = false
747+
imports_indent = "Block"
748+
imports_layout = "Mixed"
749+
imports_granularity = "Preserve"
750+
group_imports = "Preserve"
751+
reorder_imports = true
752+
reorder_modules = true
753+
reorder_impl_items = false
754+
type_punctuation_density = "Wide"
755+
space_before_colon = false
756+
space_after_colon = true
757+
spaces_around_ranges = false
758+
binop_separator = "Front"
759+
remove_nested_parens = true
760+
combine_control_expr = true
761+
short_array_element_width_threshold = 10
762+
overflow_delimited_expr = false
763+
struct_field_align_threshold = 0
764+
enum_discrim_align_threshold = 0
765+
match_arm_blocks = true
766+
match_arm_leading_pipes = "Never"
767+
force_multiline_blocks = false
768+
fn_params_layout = "Tall"
769+
brace_style = "SameLineWhere"
770+
control_brace_style = "AlwaysSameLine"
771+
trailing_semicolon = true
772+
trailing_comma = "Vertical"
773+
match_block_trailing_comma = false
774+
blank_lines_upper_bound = 1
775+
blank_lines_lower_bound = 0
776+
edition = "2015"
777+
version = "Two"
778+
inline_attribute_width = 0
779+
format_generated_files = true
780+
generated_marker_line_search_limit = 5
781+
merge_derives = true
782+
use_try_shorthand = false
783+
use_field_init_shorthand = false
784+
force_explicit_abi = true
785+
condense_wildcard_suffixes = false
786+
color = "Auto"
787+
required_version = "{}"
788+
unstable_features = false
789+
disable_all_formatting = false
790+
skip_children = false
791+
show_parse_errors = true
792+
error_on_line_overflow = false
793+
error_on_unformatted = false
794+
ignore = []
795+
emit_mode = "Files"
796+
make_backup = false
797+
"#,
798+
env!("CARGO_PKG_VERSION")
799+
);
800+
let toml = Config::default_with_style_edition(StyleEdition::Edition2024)
801+
.all_options()
802+
.to_toml()
803+
.unwrap();
804+
assert_eq!(&toml, &edition_2024_config);
805+
}
806+
807+
#[test]
808+
fn test_editions_2015_2018_2021_identical() {
809+
let get_edition_toml = |style_edition: StyleEdition| {
810+
Config::default_with_style_edition(style_edition)
811+
.all_options()
812+
.to_toml()
813+
.unwrap();
814+
};
815+
let edition2015 = get_edition_toml(StyleEdition::Edition2015);
816+
let edition2018 = get_edition_toml(StyleEdition::Edition2018);
817+
let edition2021 = get_edition_toml(StyleEdition::Edition2021);
818+
assert_eq!(edition2015, edition2018);
819+
assert_eq!(edition2018, edition2021);
820+
}
821+
715822
#[stable_only_test]
716823
#[test]
717824
fn test_as_not_nightly_channel() {

0 commit comments

Comments
 (0)