| Crates.io | test_with_parameters |
| lib.rs | test_with_parameters |
| version | 0.1.0 |
| created_at | 2021-11-26 15:51:14.749854+00 |
| updated_at | 2021-11-26 15:51:14.749854+00 |
| description | A μ-crate for parameterised unit tests. |
| homepage | |
| repository | https://github.com/matthew-healy/test_with_parameters |
| max_upload_size | |
| id | 488071 |
| size | 5,651 |
This is a μ-crate which exposes a single attribute, test_with_parameters, which can be used to create parameterised unit tests.
#[cfg(test)]
mod tests {
#[test_with_parameters(
[ "input" , "expected" ]
[ None , "Hello, World!" ]
[ Some("me") , "Hello, me!" ]
)]
fn hello_tests(input: Option<&str>, expected: &str) {
assert_eq(expected, hello(input))
}
}
This desugars to:
#[cfg(test)]
mod tests {
fn hello_tests(input: Option<&str>, expected: &str) {
assert_eq(expected, hello(input))
}
#[test]
fn hello_tests_case0() {
hello_tests(None, "Hello, World!")
}
#[test]
fn hello_tests_case1() {
hello_tests(Some("me"), hello(input))
}
}