Debian Codegraph @

tests/by-util/test_hostid.rs

raw
1 // This file is part of the uutils coreutils package.
2 //
3 // For the full copyright and license information, please view the LICENSE
4 // file that was distributed with this source code.
5
6 use regex::Regex;
7 use uutests::new_ucmd;
8
9 #[test]
10 fn test_output_format() {
11 // Output must be exactly 8 lowercase hex digits followed by a newline.
12 let re = Regex::new(r"^[0-9a-f]{8}\n$").unwrap();
13 new_ucmd!().succeeds().stdout_matches(&re);
14 }
15
16 #[test]
17 fn test_help() {
18 new_ucmd!()
19 .arg("--help")
20 .succeeds()
21 .stdout_contains("Print the numeric identifier");
22 }
23
24 #[test]
25 fn test_invalid_flag() {
26 new_ucmd!()
27 .arg("--invalid-argument")
28 .fails_with_code(1)
29 .no_stdout();
30 }