Skip to content

Commit

Permalink
Merge pull request #43 from quad/patch-1
Browse files Browse the repository at this point in the history
Make the `data` from an `ExpectFile` accessible
  • Loading branch information
quad authored Apr 1, 2024
2 parents 93b703b + 6ff13e4 commit f8b409f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ fn find_str_lit_len(str_lit_to_eof: &str) -> Option<usize> {
impl ExpectFile {
/// Checks if file contents is equal to `actual`.
pub fn assert_eq(&self, actual: &str) {
let expected = self.read();
let expected = self.data();
if actual == expected {
return;
}
Expand All @@ -445,7 +445,8 @@ impl ExpectFile {
let actual = format!("{:#?}\n", actual);
self.assert_eq(&actual)
}
fn read(&self) -> String {
/// Returns the content of this expect.
pub fn data(&self) -> String {
fs::read_to_string(self.abs_path()).unwrap_or_default().replace("\r\n", "\n")
}
fn write(&self, contents: &str) {
Expand Down

0 comments on commit f8b409f

Please sign in to comment.