annotate src/tests/utils.rs @ 96:20c1c9d7803d default tip

Fix dump failure in strings containing backquotes and double quotes.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 28 Jun 2016 01:40:55 +0100
parents e0368bea06a6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
94
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
1 use std::fs::File;
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
2 use std::io::Read;
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
3
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
4 pub fn read_file(filename: &str) -> String{
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
5 let mut file = match File::open(filename) {
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
6 Ok(file) => file,
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
7 Err(err) => {
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
8 panic!(format!("Can't find {}: {}", filename, err));
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
9 }
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
10 };
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
11 let mut content = String::new();
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
12 file.read_to_string(&mut content).unwrap();
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
13 content
e0368bea06a6 Refactor tests a little bit so it's easier to add more.
Bastien Orivel <eijebong@bananium.fr>
parents:
diff changeset
14 }