Crates.io | tinytest |
lib.rs | tinytest |
version | 0.1.1 |
source | src |
created_at | 2021-11-01 23:25:18.894925 |
updated_at | 2021-11-01 23:54:15.990986 |
description | Write more compact unit tests with a small macro. |
homepage | |
repository | https://github.com/Alonely0/tinytest/ |
max_upload_size | |
id | 475484 |
size | 5,490 |
use tinytest::unit_test;
unit_test!(test1, || some_function_in_scope("test").unwrap(), "expected output")
automatically gets translated in compile time to a standard test:
#[cfg(test)]
mod test1 {
use super::*;
#[test]
fn tiny_test() {
assert_eq!(some_function_in_scope("test").unwrap(), "expected output");
}
}
the same applies to this larger closure:
use tinytest::unit_test;
unit_test!(test2, || {
let mut c = some_function_in_scope("test").unwrap().chars()
c.next();
c.next_back();
(
c.collect::<String>(),
some_other_function_in_scope(73)
)
}, (
"expected output".to_string(),
21
)
)
that translates to:
#[cfg(test)]
mod test2 {
use super::*;
#[test]
fn tiny_test() {
assert_eq!(
{
let mut c = some_function_in_scope("test").unwrap().chars()
c.next();
c.next_back();
(
c.collect::<String>(),
some_other_function_in_scope(73)
)
}, (
"expected output".to_string(),
21
)
);
}
}