Skip to content

Commit 60a212f

Browse files
committed
#42 Test cases for error in cross cases
1 parent 0479ba3 commit 60a212f

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

resources/rstest/errors.rs

+6
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,9 @@ fn error_inject_a_fixture_that_is_already_a_value_list(f: u32) {
7171
#[rstest(f(42), f => [41, 42])]
7272
fn error_define_a_value_list_that_is_already_an_injected_fixture(f: u32) {
7373
}
74+
75+
#[rstest(a, case(42), a => [42])]
76+
fn error_define_a_value_list_that_is_already_a_case_arg(a: u32) {}
77+
78+
#[rstest(a => [42], a, case(42))]
79+
fn error_define_a_case_arg_that_is_already_a_value_list(a: u32) {}

tests/rstest/mod.rs

+27-1
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ mod should_show_correct_errors {
670670
}
671671

672672
#[test]
673-
fn if_define_case_that_is_already_an_injected_fixture() {
673+
fn if_define_a_case_arg_that_is_already_an_injected_fixture() {
674674
let (output, name) = execute();
675675

676676
assert_in!(output.stderr.str(), format!("
@@ -743,6 +743,32 @@ mod should_show_correct_errors {
743743
name).unindent());
744744
}
745745

746+
#[test]
747+
fn if_define_value_list_that_is_already_a_case_arg() {
748+
let (output, name) = execute();
749+
750+
assert_in!(output.stderr.str(), format!("
751+
error: Duplicate argument: 'a' is already defined.
752+
--> {}/src/lib.rs:75:23
753+
|
754+
75 | #[rstest(a, case(42), a => [42])]
755+
| ^",
756+
name).unindent());
757+
}
758+
759+
#[test]
760+
fn if_define_a_case_arg_that_is_already_a_value_list() {
761+
let (output, name) = execute();
762+
763+
assert_in!(output.stderr.str(), format!("
764+
error: Duplicate argument: 'a' is already defined.
765+
--> {}/src/lib.rs:78:21
766+
|
767+
78 | #[rstest(a => [42], a, case(42))]
768+
| ^",
769+
name).unindent());
770+
}
771+
746772
#[test]
747773
fn if_a_value_contains_empty_list() {
748774
let (output, name) = execute();

0 commit comments

Comments
 (0)