diff options
author | Andre Bogus <bogusandre@gmail.com> | 2016-09-23 04:59:25 +0200 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2016-11-05 22:29:26 -0400 |
commit | 02de97b8ce2762a7530cc18bba737f6ccea022a2 (patch) | |
tree | 06d934ad7866e02b85ac151b25597fdb772cf949 /tests | |
parent | 32db773d5148f2fedc57ab2b2b98d410f91a6f25 (diff) |
Use the bytecount crate for fast line counting.
Fixes #128
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.rs | 9 | ||||
-rw-r--r-- | tests/workdir.rs | 7 |
2 files changed, 15 insertions, 1 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 65962c74..48fb8185 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -789,6 +789,15 @@ clean!(regression_127, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { assert_eq!(lines, expected); }); +// See: https://github.com/BurntSushi/ripgrep/issues/128 +clean!(regression_128, "x", ".", |wd: WorkDir, mut cmd: Command| { + wd.create_bytes("foo", b"01234567\x0b\n\x0b\n\x0b\n\x0b\nx"); + cmd.arg("-n"); + + let lines: String = wd.stdout(&mut cmd); + assert_eq!(lines, "foo:5:x\n"); +}); + // See: https://github.com/BurntSushi/ripgrep/issues/131 // // TODO(burntsushi): Darwin doesn't like this test for some reason. diff --git a/tests/workdir.rs b/tests/workdir.rs index 6a79daf7..5ef3b72e 100644 --- a/tests/workdir.rs +++ b/tests/workdir.rs @@ -43,9 +43,14 @@ impl WorkDir { /// Create a new file with the given name and contents in this directory. pub fn create<P: AsRef<Path>>(&self, name: P, contents: &str) { + self.create_bytes(name, contents.as_bytes()); + } + + /// Create a new file with the given name and contents in this directory. + pub fn create_bytes<P: AsRef<Path>>(&self, name: P, contents: &[u8]) { let path = self.dir.join(name); let mut file = nice_err(&path, File::create(&path)); - nice_err(&path, file.write_all(contents.as_bytes())); + nice_err(&path, file.write_all(contents)); nice_err(&path, file.flush()); } |