in src/output.rs [1001:1041]
fn test_markdown() {
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
let file_name = "test_markdown";
let file_path = tmp_dir.path().join(file_name);
let results = vec![
(
PathBuf::from("foo/bar/a.cpp"),
PathBuf::from("foo/bar/a.cpp"),
CovResult {
lines: [(1, 10), (2, 11)].iter().cloned().collect(),
branches: BTreeMap::new(),
functions: FxHashMap::default(),
},
),
(
PathBuf::from("foo/bar/b.cpp"),
PathBuf::from("foo/bar/b.cpp"),
CovResult {
lines: [(1, 0), (2, 10), (4, 10), (5, 0), (7, 0)]
.iter()
.cloned()
.collect(),
branches: BTreeMap::new(),
functions: FxHashMap::default(),
},
),
];
output_markdown(&results, Some(&file_path), 2);
let results = &read_file(&file_path);
let expected = "| file | coverage | covered | missed_lines |
|---------------|----------|---------|--------------|
| foo/bar/a.cpp | 100.00% | 2 / 2 | |
| foo/bar/b.cpp | 40.00% | 2 / 5 | 1, 5-7 |
Total coverage: 57.14%
";
assert_eq!(results, expected);
}