Skip to content

Commit eca1eb4

Browse files
committed
Update sp_braces test for switches
1 parent 5bd945b commit eca1eb4

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

src/lint/rules/tests/spacing/nsp_inparen.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,26 @@ method this_is_some_method(conf_object_t *dummy_obj) {
3737
fn no_space_inparen_method_func_index_correct() {
3838
let rules = set_up();
3939
assert_snippet(NO_SPACE_INPAREN_METHOD_FUNC_INDEX_CORRECT, vec![], &rules);
40-
}
40+
}
41+
42+
43+
pub static NSP_INPAREN_02: &str = "
44+
bank some_bank {
45+
group some_group[ i < ( GROUP_COUNT ) ] {
46+
register some_reg is ( some_template, another_template ) {
47+
param desc = \"Register description\";
48+
}
49+
}
50+
}
51+
";
52+
#[test]
53+
fn style_check_nsp_inparen_02() {
54+
// let mut cfg = LintCfg::default();
55+
// let mut rules = instantiate_rules(&cfg);
56+
// assert_snippet(NSP_INPAREN_02, 6, &rules);
57+
// Test rule disable
58+
// cfg.nsp_inparen = None;
59+
// rules = instantiate_rules(&cfg);
60+
// assert_snippet(NSP_INPAREN_02, 0, &rules);
61+
62+
}

src/lint/rules/tests/spacing/sp_braces.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,40 @@ fn space_braces_struct_layout_bitf_correct() {
9292
rules.sp_brace.enabled = false;
9393
assert_snippet(SPACE_BRACES_STRUCT_LAYOUT_BITF_CORRECT, vec![], &rules);
9494
}
95+
96+
pub static SP_BRACES_SWITCHES: &str = "
97+
method test_switch(int some_var) {
98+
switch (some_var){
99+
case 1:
100+
print(1);
101+
break;
102+
case extra:
103+
print(\"extra\");
104+
break;
105+
case 2:
106+
print(2);
107+
break;
108+
case COMPOUND:{
109+
print(1);
110+
print(2);
111+
break;
112+
}
113+
default:
114+
print(0);
115+
break;
116+
}
117+
}
118+
";
119+
#[test]
120+
fn style_check_sp_braces_switches() {
121+
let mut rules = set_up();
122+
let expected_errors = define_expected_errors!(
123+
RuleType::SpBraces,
124+
(2, 2, 52, 53),
125+
(11, 11, 18, 19),
126+
);
127+
assert_snippet(SP_BRACES_SWITCHES, expected_errors, &rules);
128+
// Test rule disable
129+
rules.sp_brace.enabled = false;
130+
assert_snippet(SP_BRACES_SWITCHES, vec![], &rules);
131+
}

0 commit comments

Comments
 (0)