Skip to content

Commit 80c9944

Browse files
Create foo/bar in target/context-diff
1 parent 043c5f9 commit 80c9944

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/context_diff.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -747,11 +747,14 @@ mod tests {
747747
use std::fs::File;
748748
use std::str;
749749

750-
let from_filename = "foo";
751-
let _ = File::create(&format!("foo")).unwrap();
750+
let target = "target/context-diff";
751+
// test all possible six-line files.
752+
let _ = std::fs::create_dir(target);
753+
let from_filename = &format!("{target}/foo");
754+
let _ = File::create(from_filename).unwrap();
752755
let from = ["a", "b", "c", ""].join("\n");
753-
let to_filename = "bar";
754-
let _ = File::create(&format!("bar")).unwrap();
756+
let to_filename = &format!("{target}/bar");
757+
let _ = File::create(to_filename).unwrap();
755758
let to = ["a", "d", "c", ""].join("\n");
756759
let context_size: usize = 3;
757760

@@ -771,8 +774,8 @@ mod tests {
771774
let diff_full = re.replace_all(diff_full_text, "");
772775

773776
let expected_full = [
774-
"*** foo\t",
775-
"--- bar\t",
777+
"*** target/context-diff/foo\t",
778+
"--- target/context-diff/bar\t",
776779
"***************",
777780
"*** 1,3 ****",
778781
" a",
@@ -801,7 +804,7 @@ mod tests {
801804
let diff_brief_text = str::from_utf8(&diff_brief).unwrap();
802805
let re = Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [+-]\d{4}").unwrap();
803806
let diff_brief = re.replace_all(diff_brief_text, "");
804-
let expected_brief = ["*** foo\t", "--- bar\t", ""].join("\n");
807+
let expected_brief = ["*** target/context-diff/foo\t", "--- target/context-diff/bar\t", ""].join("\n");
805808
assert_eq!(diff_brief, expected_brief);
806809

807810
let nodiff_full = diff(

0 commit comments

Comments
 (0)