diff options
author | Ralf Jung <post@ralfj.de> | 2017-02-02 15:29:50 +0100 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2017-03-12 21:21:28 -0400 |
commit | d352b792944af6dc5d818b1ed3119f0914dfce38 (patch) | |
tree | 8f199062da76cdee8c7e5558ea9f8795e2160200 /tests | |
parent | 23aec586696afb5d3cda1081d63f9641caad1045 (diff) |
Add new -M/--max-columns option.
This permits setting the maximum line width with respect to the number
of bytes in a line. Omitted lines (whether part of a match, replacement
or context) are replaced with a message stating that the line was
elided.
Fixes #129
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 9e216b52..9477f32e 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1314,6 +1314,36 @@ clean!(feature_109_case_sensitive_part2, "test", ".", wd.assert_err(&mut cmd); }); +// See: https://github.com/BurntSushi/ripgrep/issues/129 +clean!(feature_129_matches, "test", ".", |wd: WorkDir, mut cmd: Command| { + wd.create("foo", "test\ntest abcdefghijklmnopqrstuvwxyz test"); + cmd.arg("-M26"); + + let lines: String = wd.stdout(&mut cmd); + let expected = "foo:test\nfoo:[Omitted long line with 2 matches]\n"; + assert_eq!(lines, expected); +}); + +// See: https://github.com/BurntSushi/ripgrep/issues/129 +clean!(feature_129_context, "test", ".", |wd: WorkDir, mut cmd: Command| { + wd.create("foo", "test\nabcdefghijklmnopqrstuvwxyz"); + cmd.arg("-M20").arg("-C1"); + + let lines: String = wd.stdout(&mut cmd); + let expected = "foo:test\nfoo-[Omitted long context line]\n"; + assert_eq!(lines, expected); +}); + +// See: https://github.com/BurntSushi/ripgrep/issues/129 +clean!(feature_129_replace, "test", ".", |wd: WorkDir, mut cmd: Command| { + wd.create("foo", "test\ntest abcdefghijklmnopqrstuvwxyz test"); + cmd.arg("-M26").arg("-rfoo"); + + let lines: String = wd.stdout(&mut cmd); + let expected = "foo:foo\nfoo:[Omitted long line with 2 replacements]\n"; + assert_eq!(lines, expected); +}); + // See: https://github.com/BurntSushi/ripgrep/issues/159 clean!(feature_159_works, "test", ".", |wd: WorkDir, mut cmd: Command| { wd.create("foo", "test\ntest"); |