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))
|
||||
.expect("no golden file");
|
||||
let expected = expected.trim_end();
|
||||
print!(" {}: ", n);
|
||||
let start = Instant::now();
|
||||
let output = run();
|
||||
let elapsed = start.elapsed();
|
||||
println!(
|
||||
" {}: {}",
|
||||
n,
|
||||
if expected == output {
|
||||
print!("OK");
|
||||
if elapsed > Duration::from_millis(10) {
|
||||
print!(" ({:?})", elapsed);
|
||||
}
|
||||
print!("\n");
|
||||
let duration = if elapsed > Duration::from_millis(10) {
|
||||
format!(" ({:?})", elapsed)
|
||||
} 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