Combine test result printing in to single expression
This commit is contained in:
parent
d80fdfabdd
commit
f3247b2e9c
18
rust/main.rs
18
rust/main.rs
@ -23,19 +23,23 @@ fn main() {
|
|||||||
fs::read_to_string(format!("../outputs/{}/{}/{}", t, puzzle.number(), n))
|
fs::read_to_string(format!("../outputs/{}/{}/{}", t, puzzle.number(), n))
|
||||||
.expect("no golden file");
|
.expect("no golden file");
|
||||||
let expected = expected.trim_end();
|
let expected = expected.trim_end();
|
||||||
print!(" {}: ", n);
|
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let output = run();
|
let output = run();
|
||||||
let elapsed = start.elapsed();
|
let elapsed = start.elapsed();
|
||||||
|
println!(
|
||||||
|
" {}: {}",
|
||||||
|
n,
|
||||||
if expected == output {
|
if expected == output {
|
||||||
print!("OK");
|
let duration = if elapsed > Duration::from_millis(10) {
|
||||||
if elapsed > Duration::from_millis(10) {
|
format!(" ({:?})", elapsed)
|
||||||
print!(" ({:?})", elapsed);
|
|
||||||
}
|
|
||||||
print!("\n");
|
|
||||||
} else {
|
} else {
|
||||||
println!("expected {}, got {}", expected, output);
|
"".to_owned()
|
||||||
};
|
};
|
||||||
|
"OK".to_owned() + &duration
|
||||||
|
} else {
|
||||||
|
format!("expected {}, got {}", expected, output)
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user