Use check_count! instead of multiple check! in separate scopes

Changes are based on the review feedback by Veykril.
This commit is contained in:
Jonas Bushart 2022-04-03 18:34:06 +00:00 committed by GitHub
parent 0cc079f3e9
commit 156f9074e1

View file

@ -302,108 +302,99 @@ fn main() {}",
#[test] #[test]
fn insert_empty_file() { fn insert_empty_file() {
{ cov_mark::check_count!(insert_empty_file, 2);
// Default configuration
cov_mark::check!(insert_empty_file); // Default configuration
// empty files will get two trailing newlines // empty files will get two trailing newlines
// this is due to the test case insert_no_imports above // this is due to the test case insert_no_imports above
check_crate( check_crate(
"foo::bar", "foo::bar",
"", "",
r"use foo::bar; r"use foo::bar;
", ",
); );
}
{ // "not group" configuration
// "not group" configuration check_with_config(
cov_mark::check!(insert_empty_file); "use external_crate2::bar::A",
check_with_config( r"",
"use external_crate2::bar::A", r"use external_crate2::bar::A;
r"",
r"use external_crate2::bar::A;
", ",
&InsertUseConfig { &InsertUseConfig {
granularity: ImportGranularity::Item, granularity: ImportGranularity::Item,
enforce_granularity: true, enforce_granularity: true,
prefix_kind: PrefixKind::Plain, prefix_kind: PrefixKind::Plain,
group: false, group: false,
skip_glob_imports: true, skip_glob_imports: true,
}, },
); );
}
} }
#[test] #[test]
fn insert_empty_module() { fn insert_empty_module() {
{ cov_mark::check_count!(insert_empty_module, 2);
// Default configuration
cov_mark::check!(insert_empty_module); // Default configuration
check( check(
"foo::bar", "foo::bar",
r" r"
mod x {$0} mod x {$0}
", ",
r" r"
mod x { mod x {
use foo::bar; use foo::bar;
} }
", ",
ImportGranularity::Item, ImportGranularity::Item,
); );
}
{ // "not group" configuration
// "not group" configuration check_with_config(
cov_mark::check!(insert_empty_module); "foo::bar",
check_with_config( r"mod x {$0}",
"foo::bar", r"mod x {
r"mod x {$0}",
r"mod x {
use foo::bar; use foo::bar;
}", }",
&InsertUseConfig { &InsertUseConfig {
granularity: ImportGranularity::Item, granularity: ImportGranularity::Item,
enforce_granularity: true, enforce_granularity: true,
prefix_kind: PrefixKind::Plain, prefix_kind: PrefixKind::Plain,
group: false, group: false,
skip_glob_imports: true, skip_glob_imports: true,
}, },
); );
}
} }
#[test] #[test]
fn insert_after_inner_attr() { fn insert_after_inner_attr() {
{ cov_mark::check_count!(insert_empty_inner_attr, 2);
// Default configuration
cov_mark::check!(insert_empty_inner_attr); // Default configuration
check_crate( check_crate(
"foo::bar", "foo::bar",
r"#![allow(unused_imports)]", r"#![allow(unused_imports)]",
r"#![allow(unused_imports)] r"#![allow(unused_imports)]
use foo::bar;", use foo::bar;",
); );
}
{ // "not group" configuration
// "not group" configuration check_with_config(
cov_mark::check!(insert_empty_inner_attr); "foo::bar",
check_with_config( r"#![allow(unused_imports)]",
"foo::bar", r"#![allow(unused_imports)]
r"#![allow(unused_imports)]",
r"#![allow(unused_imports)]
use foo::bar;", use foo::bar;",
&InsertUseConfig { &InsertUseConfig {
granularity: ImportGranularity::Item, granularity: ImportGranularity::Item,
enforce_granularity: true, enforce_granularity: true,
prefix_kind: PrefixKind::Plain, prefix_kind: PrefixKind::Plain,
group: false, group: false,
skip_glob_imports: true, skip_glob_imports: true,
}, },
); );
}
} }
#[test] #[test]