in src/reader.rs [1433:1517]
fn test_reader_finalize_file_branch() {
let mut gcno = Gcno::new();
from_path(&mut gcno, FileType::Gcno, "test/llvm/file_branch.gcno");
from_path(&mut gcno, FileType::Gcda, "test/llvm/file_branch.gcda");
gcno.stop();
let result = gcno.finalize(true);
let mut lines: BTreeMap<u32, u64> = BTreeMap::new();
[
(2, 2),
(3, 1),
(4, 1),
(5, 1),
(6, 1),
(8, 1),
(10, 2),
(13, 1),
(14, 0),
(16, 1),
(18, 1),
(21, 0),
(22, 0),
(24, 0),
(25, 0),
(26, 0),
(28, 0),
(32, 1),
]
.iter()
.for_each(|x| {
lines.insert(x.0, x.1);
});
let mut functions: FunctionMap = FxHashMap::default();
functions.insert(
String::from("foo"),
Function {
start: 1,
executed: true,
},
);
functions.insert(
String::from("bar"),
Function {
start: 12,
executed: true,
},
);
functions.insert(
String::from("oof"),
Function {
start: 20,
executed: false,
},
);
functions.insert(
String::from("main"),
Function {
start: 31,
executed: true,
},
);
let mut branches: BTreeMap<u32, Vec<bool>> = BTreeMap::new();
[
(2, vec![true, true]),
(3, vec![true, false]),
(13, vec![false, true]),
(21, vec![false, false, false, false]),
]
.iter()
.for_each(|x| {
branches.insert(x.0, x.1.clone());
});
let expected = vec![(
String::from("file_branch.c"),
CovResult {
lines,
branches,
functions,
},
)];
assert_eq!(result, expected);
}