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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
use std::convert:: { From };
use std::option:: { Option };
use std::io:: { Result };
use std::io::prelude::*;
use parser:: { parse_record };
#[derive(Debug, PartialEq, Clone)]
pub enum LCOVRecord
{
TestName(Option<String>),
SourceFile(String),
Data(LineData),
FunctionName(FunctionName),
FunctionData(FunctionData),
FunctionsFound(u32),
FunctionsHit(u32),
LinesHit(u32),
LinesFound(u32),
BranchData(BranchData),
BranchesFound(u32),
BranchesHit(u32),
EndOfRecord
}
#[derive(Debug, PartialEq, Clone)]
pub struct LineData {
pub line: u32,
pub count: u32,
pub checksum: Option<String>
}
#[derive(Debug, PartialEq, Clone)]
pub struct FunctionName {
pub name: String,
pub line: u32
}
#[derive(Debug, PartialEq, Clone)]
pub struct FunctionData {
pub name: String,
pub count: u32
}
#[derive(Debug, PartialEq, Clone)]
pub struct BranchData {
pub line: u32,
pub block: u32,
pub branch: u32,
pub taken: u32
}
impl<'a> From<&'a str> for LCOVRecord {
fn from(input: &'a str) -> Self {
parse_record(input).unwrap()
}
}
impl From<LineData> for LCOVRecord {
fn from(input: LineData) -> Self {
LCOVRecord::Data(input)
}
}
impl From<FunctionName> for LCOVRecord {
fn from(input: FunctionName) -> Self {
LCOVRecord::FunctionName(input)
}
}
impl From<FunctionData> for LCOVRecord {
fn from(input: FunctionData) -> Self {
LCOVRecord::FunctionData(input)
}
}
impl From<BranchData> for LCOVRecord {
fn from(input: BranchData) -> Self {
LCOVRecord::BranchData(input)
}
}
pub trait RecordWrite {
fn write_records<T: Write>(&self, output: &mut T) -> Result<()>;
}