pub use self::parse::*;
use std::path::PathBuf;
mod display;
mod parse;
#[cfg(test)]
mod tests;
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub enum Record {
TestName {
name: String,
},
SourceFile {
path: PathBuf,
},
FunctionName {
name: String,
start_line: u32,
},
FunctionData {
name: String,
count: u64,
},
FunctionsFound {
found: u32,
},
FunctionsHit {
hit: u32,
},
BranchData {
line: u32,
block: u32,
branch: u32,
taken: Option<u64>,
},
BranchesFound {
found: u32,
},
BranchesHit {
hit: u32,
},
LineData {
line: u32,
count: u64,
checksum: Option<String>,
},
LinesFound {
found: u32,
},
LinesHit {
hit: u32,
},
EndOfRecord,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub enum RecordKind {
TestName,
SourceFile,
FunctionName,
FunctionData,
FunctionsFound,
FunctionsHit,
BranchData,
BranchesFound,
BranchesHit,
LineData,
LinesFound,
LinesHit,
EndOfRecord,
}
macro_rules! kind_impl {
($rec:expr; $($kind:ident),*) => {
match $rec {
$(Record::$kind { .. } => RecordKind::$kind),*
}
}
}
impl Record {
pub fn kind(&self) -> RecordKind {
kind_impl! {
*self;
TestName, SourceFile,
FunctionName, FunctionData, FunctionsFound, FunctionsHit,
BranchData, BranchesFound, BranchesHit,
LineData, LinesFound, LinesHit,
EndOfRecord
}
}
}
impl RecordKind {
pub fn as_str(&self) -> &'static str {
use RecordKind::*;
match *self {
TestName => "TN",
SourceFile => "SF",
FunctionName => "FN",
FunctionData => "FNDA",
FunctionsFound => "FNF",
FunctionsHit => "FNH",
BranchData => "BRDA",
BranchesFound => "BRF",
BranchesHit => "BRH",
LineData => "DA",
LinesFound => "LF",
LinesHit => "LH",
EndOfRecord => "end_of_record",
}
}
}