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
#[path = "common/support.rs"]
mod common;
#[cfg(test)]
pub mod tests {
use crate::common::assert_contains_all;
use crate::common::example::Example;
fn example() -> Example {
Example::new("test-mutex-async-lock", "basic_mutex_async_lock")
}
// cargo run -p test-mutex-async-lock --example basic_mutex_async_lock --features hotpath
#[test]
fn test_basic_output() {
let stdout = example().stdout();
assert_contains_all(
&stdout,
&[
"async-lock Mutex example completed!",
"mutexes",
"counter",
"Locks",
"Wait avg",
"Acq avg",
],
);
}
// cargo run -p test-mutex-async-lock --example basic_mutex_async_lock --features hotpath (json)
#[test]
fn test_json_output() {
let stdout = example().json().stdout();
assert_contains_all(
&stdout,
&[
"\"mutexes\"",
"\"label\":\"counter\"",
"\"count\":6",
"\"wait_avg\"",
"\"acquire_avg\"",
"\"wait_percentiles\"",
"\"acquire_percentiles\"",
],
);
}
}