diff options
author | Balaji Sivaraman <balaji@balajisivaraman.com> | 2018-02-20 21:03:07 +0530 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-03-10 10:38:25 -0500 |
commit | 27fc9f2fd341bd3ed672f79d43bf983514188b96 (patch) | |
tree | 6a0d42ebe069ac6077eace1968332246ab51cb77 /tests | |
parent | 96f73293c0b734d91b55ad1e6940da0f706eed65 (diff) |
search: add a --count-matches flag
This commit introduces a new flag, --count-matches, which will cause
ripgrep to report a total count of all matches instead of a count of
total lines matched.
Closes #566, Closes #814
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 7ae23895..b35f23f6 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -412,6 +412,20 @@ sherlock!(count, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { assert_eq!(lines, expected); }); +sherlock!(count_matches, "the", ".", |wd: WorkDir, mut cmd: Command| { + cmd.arg("--count-matches"); + let lines: String = wd.stdout(&mut cmd); + let expected = "sherlock:4\n"; + assert_eq!(lines, expected); +}); + +sherlock!(count_matches_inverted, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { + cmd.arg("--count-matches").arg("--invert-match"); + let lines: String = wd.stdout(&mut cmd); + let expected = "sherlock:4\n"; + assert_eq!(lines, expected); +}); + sherlock!(files_with_matches, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { cmd.arg("--files-with-matches"); let lines: String = wd.stdout(&mut cmd); |