summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBalaji Sivaraman <balaji@balajisivaraman.com>2018-02-20 21:03:07 +0530
committerAndrew Gallant <jamslam@gmail.com>2018-03-10 10:38:25 -0500
commit27fc9f2fd341bd3ed672f79d43bf983514188b96 (patch)
tree6a0d42ebe069ac6077eace1968332246ab51cb77 /tests
parent96f73293c0b734d91b55ad1e6940da0f706eed65 (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.rs14
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);