diff options
author | Andrew Gallant <jamslam@gmail.com> | 2016-09-26 19:21:17 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2016-09-26 19:21:17 -0400 |
commit | 7a3fd1f23fe7a4d679fb1fb7d13884a653e5d4f5 (patch) | |
tree | 22e9bf417c21f52ba39590825b49d02b01b72855 /tests | |
parent | d30640344090fc3ffde6d58e0c5a4c928fb00990 (diff) |
Add a --null flag.
This flag causes a NUL byte to follow any file path in ripgrep's output.
Closes #89.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 582eb841..d6767065 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -770,6 +770,48 @@ sherlock:be, to a very large extent, the result of luck. Sherlock Holmes assert_eq!(lines, expected); }); +// See: https://github.com/BurntSushi/ripgrep/issues/89 +sherlock!(feature_89_files_with_matches, "Sherlock", ".", +|wd: WorkDir, mut cmd: Command| { + cmd.arg("--null").arg("--files-with-matches"); + + let lines: String = wd.stdout(&mut cmd); + assert_eq!(lines, "sherlock\x00"); +}); + +// See: https://github.com/BurntSushi/ripgrep/issues/89 +sherlock!(feature_89_count, "Sherlock", ".", +|wd: WorkDir, mut cmd: Command| { + cmd.arg("--null").arg("--count"); + + let lines: String = wd.stdout(&mut cmd); + assert_eq!(lines, "sherlock\x002\n"); +}); + +// See: https://github.com/BurntSushi/ripgrep/issues/89 +sherlock!(feature_89_files, "NADA", ".", +|wd: WorkDir, mut cmd: Command| { + cmd.arg("--null").arg("--files"); + + let lines: String = wd.stdout(&mut cmd); + assert_eq!(lines, "sherlock\x00"); +}); + +// See: https://github.com/BurntSushi/ripgrep/issues/89 +sherlock!(feature_89_match, "Sherlock", ".", +|wd: WorkDir, mut cmd: Command| { + cmd.arg("--null").arg("-C1"); + + let lines: String = wd.stdout(&mut cmd); + let expected = "\ +sherlock\x00For the Doctor Watsons of this world, as opposed to the Sherlock +sherlock\x00Holmeses, success in the province of detective work must always +sherlock\x00be, to a very large extent, the result of luck. Sherlock Holmes +sherlock\x00can extract a clew from a wisp of straw or a flake of cigar ash; +"; + assert_eq!(lines, expected); +}); + #[test] fn binary_nosearch() { let wd = WorkDir::new("binary_nosearch"); |