Debian Codegraph @

debian/rust-vendor/rstest/tests/resources/fixture/rename.rs

raw
1 use rstest::*;
2
3 #[fixture]
4 fn very_long_and_boring_name(#[default(42)] inject: u32) -> u32 {
5 inject
6 }
7
8 mod sub_module {
9 use super::*;
10
11 #[fixture]
12 pub fn mod_fixture() -> u32 {
13 42
14 }
15 }
16
17 #[fixture(very_long_and_boring_name as foo)]
18 fn compact(foo: u32) -> u32 {
19 foo
20 }
21
22 #[fixture(very_long_and_boring_name(21) as foo)]
23 fn compact_injected(foo: u32) -> u32 {
24 foo
25 }
26
27 #[fixture(sub_module::mod_fixture as foo)]
28 fn compact_from_mod(foo: u32) -> u32 {
29 foo
30 }
31
32 #[fixture]
33 fn attribute(#[from(very_long_and_boring_name)] foo: u32) -> u32 {
34 foo
35 }
36
37 #[fixture]
38 fn attribute_mod(#[from(sub_module::mod_fixture)] foo: u32) -> u32 {
39 foo
40 }
41
42 #[fixture]
43 fn attribute_injected(
44 #[from(very_long_and_boring_name)]
45 #[with(21)]
46 foo: u32,
47 ) -> u32 {
48 foo
49 }
50
51 #[rstest]
52 fn test(
53 compact: u32,
54 attribute: u32,
55 attribute_mod: u32,
56 compact_from_mod: u32,
57 compact_injected: u32,
58 attribute_injected: u32,
59 ) {
60 assert_eq!(compact, attribute);
61 assert_eq!(attribute, attribute_mod);
62 assert_eq!(attribute_mod, compact_from_mod);
63 assert_eq!(compact_injected, attribute_injected);
64 }