Skip to content

Commit 6e91d97

Browse files
committed
#42 First integration test for cases in place. Now rstest parse also
cases data
1 parent 76d1c18 commit 6e91d97

File tree

5 files changed

+289
-57
lines changed

5 files changed

+289
-57
lines changed

resources/rstest/happy_path_cases.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use rstest::rstest;
2+
3+
#[rstest(
4+
expected, input,
5+
case(4, "ciao"),
6+
case(3, "Foo")
7+
)]
8+
fn strlen_test(expected: usize, input: &str) {
9+
assert_eq!(expected, input.len());
10+
}

src/lib.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ use crate::parse::{
202202
parametrize::{ParametrizeData, ParametrizeInfo, TestCase},
203203
rstest::{RsTestAttributes, RsTestInfo},
204204
};
205-
use crate::refident::{MaybeIdent, RefIdent};
205+
use crate::refident::MaybeIdent;
206206
use crate::resolver::{arg_2_fixture, Resolver};
207207

208208
// Test utility module
@@ -586,12 +586,13 @@ fn fn_args_has_ident(fn_decl: &ItemFn, ident: &Ident) -> bool {
586586

587587
type Errors<'a> = Box<dyn Iterator<Item=syn::Error> + 'a>;
588588

589-
fn missed_arguments_errors<'a, I: RefIdent + Spanned + 'a>(test: &'a ItemFn, args: impl Iterator<Item=&'a I> + 'a) -> Errors<'a> {
589+
fn missed_arguments_errors<'a, I: MaybeIdent + Spanned + 'a>(test: &'a ItemFn, args: impl Iterator<Item=&'a I> + 'a) -> Errors<'a> {
590590
Box::new(
591591
args
592-
.filter(move |&p| !fn_args_has_ident(test, p.ident()))
593-
.map(|missed| syn::Error::new(missed.span(),
594-
&format!("Missed argument: '{}' should be a test function argument.", missed.ident()),
592+
.filter_map(|it| it.maybe_ident().map(|ident| (it, ident)))
593+
.filter(move |(_, ident)| !fn_args_has_ident(test, ident))
594+
.map(|(missed, ident)| syn::Error::new(missed.span(),
595+
&format!("Missed argument: '{}' should be a test function argument.", ident),
595596
))
596597
)
597598
}

src/parse/parametrize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl ToTokens for ParametrizeItem {
113113
}
114114
}
115115

116-
#[derive(Debug)]
116+
#[derive(PartialEq, Debug)]
117117
/// A test case instance data. Contains a list of arguments. It is parsed by parametrize
118118
/// attributes.
119119
pub(crate) struct TestCase {

0 commit comments

Comments
 (0)