summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoman Proskuryakov <humbug@deeptown.org>2017-04-20 18:02:52 +0300
committerAndrew Gallant <jamslam@gmail.com>2017-04-21 08:11:55 -0400
commit362abed44a000da3b31e5dd027e16eb4e36e1bed (patch)
treea8eaa8082c2c3c59cdaa330d287e13b75de102ac /tests
parentc50b8b4125dc7f1181944dd92d0aca97c2450421 (diff)
Fix reiteration of the first found match with --only-mathing flag
Fixes #451
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index 38812c4e..95c6e6a5 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1607,6 +1607,51 @@ fn regression_391() {
assert_eq!(lines, "bar.py\n");
}
+// See: https://github.com/BurntSushi/ripgrep/issues/451
+#[test]
+fn regression_451_only_matching_as_in_issue() {
+ let wd = WorkDir::new("regression_451_only_matching");
+ let path = "digits.txt";
+ wd.create(path, "1 2 3\n");
+
+ let mut cmd = wd.command();
+ cmd.arg("[0-9]+").arg(path).arg("--only-matching");
+ let lines: String = wd.stdout(&mut cmd);
+
+ let expected = "\
+1
+2
+3
+";
+
+ assert_eq!(lines, expected);
+}
+
+// See: https://github.com/BurntSushi/ripgrep/issues/451
+#[test]
+fn regression_451_only_matching() {
+ let wd = WorkDir::new("regression_451_only_matching");
+ let path = "digits.txt";
+ wd.create(path, "1 2 3\n123\n");
+
+ let mut cmd = wd.command();
+ cmd.arg("[0-9]").arg(path)
+ .arg("--only-matching")
+ .arg("--column");
+ let lines: String = wd.stdout(&mut cmd);
+
+ let expected = "\
+1:1:1
+1:3:2
+1:5:3
+2:1:1
+2:2:2
+2:3:3
+";
+
+ assert_eq!(lines, expected);
+}
+
#[test]
fn type_list() {
let wd = WorkDir::new("type_list");