rstest icon indicating copy to clipboard operation
rstest copied to clipboard

`Wrong case signature` error on pattern in function parameter

Open sharksforarms opened this issue 2 years ago • 1 comments

Hello! I'm attempting to use patern matching in funciton parameters but I'm getting wrong case signature. Is this currently supported in rstest?

I tried to use cargo expand to see what get's generated, but it doesn't seem to be giving me the generated rstest code for test_test_bad below. How could I debug this?

Reference: https://doc.rust-lang.org/book/ch18-01-all-the-places-for-patterns.html#function-parameters

Error: Wrong case signature: should match the given parameters list.

Example:

fn args_tuple(arg1: u8, (arg2, arg3): (u8, u8)) {
    todo!();
}

fn main() {
    args_tuple(1, (2,3));
}

#[cfg(test)]
mod tests {
    use super::args_tuple;
    use rstest::*;

    #[rstest]
    #[case(1, (2, 3))]
    fn test_test_good(#[case] arg1: u8, #[case] args: (u8, u8)) {
        args_tuple(arg1, args);
    }

    #[rstest]
    #[case(1, (2, 3))]
    fn test_test_bad(#[case] arg1: u8, #[case] (arg2, arg3): (u8, u8)) {
        args_tuple(arg1, (arg2, arg3));
    }
}

sharksforarms avatar Jun 27 '23 14:06 sharksforarms

I'm sorry, this feature is not implemented yet... But could be a great idea to support it

la10736 avatar Jun 27 '23 15:06 la10736