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
//!
//! The macro in this file takes 3 arguments:
//! 1. The name of the function to generate
//! 2. The return type of the function
//! 3. A brace-enclosed, comma-separated list of module
//! names
//!
//! Each module in (3) should match the basename of a file in `tests/messages` but with dashes
//! replaced by underscores to make it a valid Rust identifier. When the generated function is
//! called with a filename that matches one of these modules, it will call the `expected()`
//! function of that module, which should return an object of the return type specified in the
//! macro, which will be returned as Some(expected()). If the generated function is called with a
//! filename that does not match any module, it will return `None`.
//!
//! # Example #
//!
//! ## Macro call ##
//!
//! ```ignore
//! use ssh_agent_lib::proto::Request;
//!
//! make_expected_fn!(get_expected_request -> Request, {
//! req_hello
//! });
//! ```
//!
//! ## Usage of generated function in test code ##
//!
//! ```ignore
//! let test_data_path = PathBuf::from("test/messages/req-hello.bin");
//! if let Some(expected) = path::to::get_expected_request(&test_data_path) {
//! assert_eq!(expected, ...);
//! }
//! ```
//!
//! ## `path/to/req_hello.rs` ##
//!
//! ```ignore
//! pub fn expected() -> Request {
//! ...
//! }
//! ```