1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
pub use parameterized_macro::parameterized;
#[macro_export]
macro_rules! ide {
() => {
#[test]
fn __mark_with_test_intent() {}
};
}
#[cfg(test)]
mod tests {
use crate::ide;
use crate::parameterized as pm;
fn add5<T: Into<u32>>(component: T) -> u32 {
component.into() + 5
}
mod readme_test {
use super::*;
ide!();
#[pm(input = {
0, 1, 2
}, expected = {
5, 6, 7
})]
fn test_add5(input: u16, expected: u32) {
assert_eq!(add5(input), expected)
}
}
mod marked_as_test_module {
use super::*;
ide!();
#[pm(input = { 2, 3, 4 }, output = { 4, 6, 8 })]
fn test_times2(input: i32, output: i32) {
let times2 = |receiver: i32| receiver * 2;
assert_eq!(times2(input), output);
}
}
mod transitive_attrs {
use super::*;
ide!();
#[pm(input = { None, None, None })]
#[should_panic]
fn numbers(input: Option<()>) {
input.unwrap()
}
}
}