diff options
author | Balaji Sivaraman <balaji@balajisivaraman.com> | 2018-02-21 22:16:45 +0530 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-03-10 10:15:19 -0500 |
commit | b006943c01561a4ae5b928081d1bb4087b599e19 (patch) | |
tree | 88c402f4edc91b808260c9c7c9ea4e0a5790c089 /tests | |
parent | 91d0756f62790356012d692a7b340df92b54beac (diff) |
search: add -b/--byte-offset flag
This commit adds support for printing 0-based byte offset before each
line. We handle corner cases such as `-o/--only-matching` and
`-C/--context` as well.
Closes #812
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 6becfe0f..7ae23895 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -395,6 +395,16 @@ sherlock!(csglob, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { assert_eq!(lines, "file2.html:Sherlock\n"); }); +sherlock!(byte_offset_only_matching, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { + cmd.arg("-b").arg("-o"); + let lines: String = wd.stdout(&mut cmd); + let expected = "\ +sherlock:56:Sherlock +sherlock:177:Sherlock +"; + assert_eq!(lines, expected); +}); + sherlock!(count, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { cmd.arg("--count"); let lines: String = wd.stdout(&mut cmd); |