diff options
author | Marc Tiehuis <marctiehuis@gmail.com> | 2017-04-02 09:55:58 +1200 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2017-04-12 18:14:23 -0400 |
commit | 66efbad871620fe2dbe675438fdc8d9922e72826 (patch) | |
tree | f29d2e1b4da5adb8eb6c94d45c5e239b44030e82 /tests | |
parent | 1f2a9b03062d14491b04a644409fdb8e62f77711 (diff) |
Add dfa-size-limit and regex-size-limit arguments
Fixes #362.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.rs | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 578dbcba..ef332ae7 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -455,7 +455,6 @@ sherlock!(max_filesize_parse_no_suffix, "Sherlock", ".", let expected = "\ foo "; - assert_eq!(lines, expected); }); @@ -470,7 +469,6 @@ sherlock!(max_filesize_parse_k_suffix, "Sherlock", ".", let expected = "\ foo "; - assert_eq!(lines, expected); }); @@ -485,10 +483,19 @@ sherlock!(max_filesize_parse_m_suffix, "Sherlock", ".", let expected = "\ foo "; - assert_eq!(lines, expected); }); +sherlock!(max_filesize_suffix_overflow, "Sherlock", ".", +|wd: WorkDir, mut cmd: Command| { + wd.remove("sherlock"); + wd.create_size("foo", 1000000); + + // 2^35 * 2^30 would otherwise overflow + cmd.arg("--max-filesize").arg("34359738368G").arg("--files"); + wd.assert_err(&mut cmd); +}); + sherlock!(ignore_hidden, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { wd.remove("sherlock"); wd.create(".sherlock", hay::SHERLOCK); @@ -1443,6 +1450,37 @@ clean!(feature_275_pathsep, "test", ".", |wd: WorkDir, mut cmd: Command| { assert_eq!(lines, "fooZbar:test\n"); }); +// See: https://github.com/BurntSushi/ripgrep/issues/362 +sherlock!(feature_362_dfa_size_limit, r"For\s", +|wd: WorkDir, mut cmd: Command| { + // This should fall back to the nfa engine but should still produce the + // expected result. + cmd.arg("--dfa-size-limit").arg("10"); + let lines: String = wd.stdout(&mut cmd); + let expected = "\ +For the Doctor Watsons of this world, as opposed to the Sherlock +"; + assert_eq!(lines, expected); +}); + +sherlock!(feature_362_exceeds_regex_size_limit, r"[0-9]\w+", +|wd: WorkDir, mut cmd: Command| { + cmd.arg("--regex-size-limit").arg("10K"); + wd.assert_err(&mut cmd); +}); + +#[cfg(target_pointer_width = "32")] +sherlock!(feature_362_u64_to_narrow_usize_suffix_overflow, "Sherlock", ".", +|wd: WorkDir, mut cmd: Command| { + wd.remove("sherlock"); + wd.create_size("foo", 1000000); + + // 2^35 * 2^20 is ok for u64, but not for usize + cmd.arg("--dfa-size-limit").arg("34359738368M").arg("--files"); + wd.assert_err(&mut cmd); +}); + + // See: https://github.com/BurntSushi/ripgrep/issues/419 sherlock!(feature_419_zero_as_shortcut_for_null, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { |