Bye bye println() debugging
This commit is contained in:
parent
c90c0f7848
commit
7e8819f4d2
|
@ -233,21 +233,15 @@ fn create_book(passing_test: bool) -> TempDir {
|
||||||
/// Read the contents of the provided file into memory and then iterate through
|
/// Read the contents of the provided file into memory and then iterate through
|
||||||
/// the list of strings asserting that the file contains all of them.
|
/// the list of strings asserting that the file contains all of them.
|
||||||
fn assert_contains_strings<P: AsRef<Path>>(filename: P, strings: &[&str]) {
|
fn assert_contains_strings<P: AsRef<Path>>(filename: P, strings: &[&str]) {
|
||||||
println!("Checking {}", filename.as_ref().display());
|
let filename = filename.as_ref();
|
||||||
println!();
|
|
||||||
|
|
||||||
let mut content = String::new();
|
let mut content = String::new();
|
||||||
File::open(filename)
|
File::open(&filename)
|
||||||
.expect("Couldn't open the provided file")
|
.expect("Couldn't open the provided file")
|
||||||
.read_to_string(&mut content)
|
.read_to_string(&mut content)
|
||||||
.unwrap();
|
.expect("Couldn't read the file's contents");
|
||||||
|
|
||||||
println!("{}", content);
|
|
||||||
println!();
|
|
||||||
println!();
|
|
||||||
|
|
||||||
for s in strings {
|
for s in strings {
|
||||||
println!("Checking for {:?}", s);
|
assert!(content.contains(s), "Searching for {:?} in {}\n\n{}", s, filename.display(), content);
|
||||||
assert!(content.contains(s));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue