6
6
//! # Examples
7
7
//!
8
8
//! ```rust,no_run
9
+ //! fn some_func(num: usize) -> usize {
10
+ //! // ...
11
+ //! # 10
12
+ //! }
13
+ //!
9
14
//! tryfn::Harness::new(
10
15
//! "tests/fixtures/invalid",
11
16
//! setup,
12
17
//! test,
13
18
//! )
14
19
//! .select(["tests/cases/*.in"])
15
- //! .action_env("SNAPSHOTS")
16
20
//! .test();
17
21
//!
18
22
//! fn setup(input_path: std::path::PathBuf) -> tryfn::Case {
29
33
//! let raw = std::fs::read_to_string(input_path)?;
30
34
//! let num = raw.parse::<usize>()?;
31
35
//!
32
- //! let actual = num + 10 ;
36
+ //! let actual = some_func( num) ;
33
37
//!
34
38
//! Ok(actual)
35
39
//! }
38
42
use libtest_mimic:: Trial ;
39
43
40
44
pub use snapbox:: assert:: Action ;
45
+ pub use snapbox:: data:: DataFormat ;
41
46
pub use snapbox:: Data ;
42
47
43
48
/// [`Harness`] for discovering test inputs and asserting against snapshot files
87
92
88
93
/// Path patterns for selecting input files
89
94
///
90
- /// This used gitignore syntax
95
+ /// This uses gitignore syntax
91
96
pub fn select < ' p > ( mut self , patterns : impl IntoIterator < Item = & ' p str > ) -> Self {
92
97
let mut overrides = ignore:: overrides:: OverrideBuilder :: new ( & self . root ) ;
93
98
for line in patterns {
@@ -160,6 +165,7 @@ where
160
165
}
161
166
}
162
167
168
+ /// Function signature for generating a test [`Case`] from a path fixture
163
169
pub trait Setup {
164
170
fn setup ( & self , fixture : std:: path:: PathBuf ) -> Case ;
165
171
}
@@ -173,6 +179,7 @@ where
173
179
}
174
180
}
175
181
182
+ /// Function signature for running a test [`Case`]
176
183
pub trait Test < S , E >
177
184
where
178
185
S : std:: fmt:: Display ,
@@ -192,7 +199,7 @@ where
192
199
}
193
200
}
194
201
195
- /// A test case enumerated by the [`Harness`] with data from the `setup` function
202
+ /// A test case enumerated by the [`Harness`] with data from the [`Setup`] function
196
203
pub struct Case {
197
204
/// Display name
198
205
pub name : String ,
0 commit comments