fix tests
This commit is contained in:
parent
da04cb77a8
commit
674c9cc4d3
3 changed files with 14 additions and 7 deletions
|
@ -28,6 +28,10 @@ impl Day {
|
|||
debug_assert!(day != 0 && day <= 25);
|
||||
Self(day)
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> u8 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Day {
|
||||
|
|
|
@ -204,6 +204,8 @@ mod child_commands {
|
|||
mod tests {
|
||||
use super::parse_exec_time;
|
||||
|
||||
use crate::Day;
|
||||
|
||||
#[test]
|
||||
fn test_well_formed() {
|
||||
let res = parse_exec_time(
|
||||
|
@ -212,7 +214,7 @@ mod child_commands {
|
|||
"Part 2: 10 (74.13ms @ 99999 samples)".into(),
|
||||
"".into(),
|
||||
],
|
||||
1,
|
||||
Day::new(1).unwrap(),
|
||||
);
|
||||
assert_approx_eq!(res.total_nanos, 74130074.13_f64);
|
||||
assert_eq!(res.part_1.unwrap(), "74.13ns");
|
||||
|
@ -227,7 +229,7 @@ mod child_commands {
|
|||
"Part 2: 10s (100ms @ 1 samples)".into(),
|
||||
"".into(),
|
||||
],
|
||||
1,
|
||||
Day::new(1).unwrap(),
|
||||
);
|
||||
assert_approx_eq!(res.total_nanos, 2100000000_f64);
|
||||
assert_eq!(res.part_1.unwrap(), "2s");
|
||||
|
@ -242,7 +244,7 @@ mod child_commands {
|
|||
"Part 2: ✖ ".into(),
|
||||
"".into(),
|
||||
],
|
||||
1,
|
||||
Day::new(1).unwrap(),
|
||||
);
|
||||
assert_approx_eq!(res.total_nanos, 0_f64);
|
||||
assert_eq!(res.part_1.is_none(), true);
|
||||
|
|
|
@ -73,7 +73,7 @@ fn construct_table(prefix: &str, timings: Vec<Timings>, total_millis: f64) -> St
|
|||
let path = get_path_for_bin(timing.day);
|
||||
lines.push(format!(
|
||||
"| [Day {}]({}) | `{}` | `{}` |",
|
||||
timing.day,
|
||||
timing.day.into_inner(),
|
||||
path,
|
||||
timing.part_1.unwrap_or_else(|| "-".into()),
|
||||
timing.part_2.unwrap_or_else(|| "-".into())
|
||||
|
@ -105,23 +105,24 @@ pub fn update(timings: Vec<Timings>, total_millis: f64) -> Result<(), Error> {
|
|||
#[cfg(feature = "test_lib")]
|
||||
mod tests {
|
||||
use super::{update_content, Timings, MARKER};
|
||||
use crate::Day;
|
||||
|
||||
fn get_mock_timings() -> Vec<Timings> {
|
||||
vec![
|
||||
Timings {
|
||||
day: 1,
|
||||
day: Day::new(1).unwrap(),
|
||||
part_1: Some("10ms".into()),
|
||||
part_2: Some("20ms".into()),
|
||||
total_nanos: 3e+10,
|
||||
},
|
||||
Timings {
|
||||
day: 2,
|
||||
day: Day::new(2).unwrap(),
|
||||
part_1: Some("30ms".into()),
|
||||
part_2: Some("40ms".into()),
|
||||
total_nanos: 7e+10,
|
||||
},
|
||||
Timings {
|
||||
day: 4,
|
||||
day: Day::new(4).unwrap(),
|
||||
part_1: Some("40ms".into()),
|
||||
part_2: Some("50ms".into()),
|
||||
total_nanos: 9e+10,
|
||||
|
|
Loading…
Add table
Reference in a new issue