Skip to content

Commit

Permalink
#42 matrix end to end tests are in place
Browse files Browse the repository at this point in the history
  • Loading branch information
la10736 committed Oct 14, 2019
1 parent 6fc2318 commit 89b0572
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 29 deletions.
9 changes: 9 additions & 0 deletions resources/rstest/matrix/simple.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use rstest::rstest;

#[rstest(
expected => [4, 2*3-2],
input => ["ciao", "buzz"],
)]
fn strlen_test(expected: usize, input: &str) {
assert_eq!(expected, input.len());
}
88 changes: 59 additions & 29 deletions tests/rstest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,35 @@ fn impl_input() {
.assert(output);
}

#[test]
fn should_reject_no_item_function() {
let (output, name) = run_test("reject_no_item_function.rs");

assert_in!(output.stderr.str(), format!("
error: expected `fn`
--> {}/src/lib.rs:4:1
|
4 | struct Foo;
| ^^^^^^
", name).unindent());

assert_in!(output.stderr.str(), format!("
error: expected `fn`
--> {}/src/lib.rs:7:1
|
7 | impl Foo {{}}
| ^^^^
", name).unindent());

assert_in!(output.stderr.str(), format!("
error: expected `fn`
--> {}/src/lib.rs:10:1
|
10 | mod mod_baz {{}}
| ^^^
", name).unindent());
}

mod dump_input_values {
use super::*;

Expand Down Expand Up @@ -158,35 +187,6 @@ mod dump_input_values {
}
}

#[test]
fn should_reject_no_item_function() {
let (output, name) = run_test("reject_no_item_function.rs");

assert_in!(output.stderr.str(), format!("
error: expected `fn`
--> {}/src/lib.rs:4:1
|
4 | struct Foo;
| ^^^^^^
", name).unindent());

assert_in!(output.stderr.str(), format!("
error: expected `fn`
--> {}/src/lib.rs:7:1
|
7 | impl Foo {{}}
| ^^^^
", name).unindent());

assert_in!(output.stderr.str(), format!("
error: expected `fn`
--> {}/src/lib.rs:10:1
|
10 | mod mod_baz {{}}
| ^^^
", name).unindent());
}

mod single {
use super::*;

Expand Down Expand Up @@ -580,4 +580,34 @@ mod should_show_correct_errors {
| ^",
name).unindent());
}
}

mod matrix {
use super::*;

fn res(name: impl AsRef<Path>) -> impl AsRef<Path> {
Path::new("matrix").join(name.as_ref())
}

#[test]
fn should_compile() {
let output = prj(res("simple.rs"))
.compile()
.unwrap();

assert_eq!(Some(0), output.status.code(), "Compile error due: {}", output.stderr.str())
}

#[test]
fn happy_path() {
let (output, _) = run_test(res("simple.rs"));

TestResults::new()
.ok("strlen_test::case_1_1")
.ok("strlen_test::case_1_2")
.ok("strlen_test::case_2_1")
.ok("strlen_test::case_2_2")
.assert(output);
}

}

0 comments on commit 89b0572

Please sign in to comment.