mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-04 21:52:54 +02:00
globset: add opt-in Arbitrary
trait implementations
This feature is mandatory when using `Glob` in fuzz testing. Closes #2720
This commit is contained in:
committed by
Andrew Gallant
parent
5548e538b1
commit
95979048c9
22
fuzz/fuzz_targets/fuzz_glob.rs
Normal file
22
fuzz/fuzz_targets/fuzz_glob.rs
Normal file
@ -0,0 +1,22 @@
|
||||
#![no_main]
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use globset::Glob;
|
||||
|
||||
libfuzzer_sys::fuzz_target!(|glob_str: &str| {
|
||||
let Ok(glob) = Glob::new(glob_str) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Ok(glob2) = Glob::from_str(glob_str) else {
|
||||
return;
|
||||
};
|
||||
|
||||
// Verify that a `Glob` constructed with `new` is the same as a `Glob`` constructed
|
||||
// with `from_str`.
|
||||
assert_eq!(glob, glob2);
|
||||
|
||||
// Verify that `Glob::glob` produces the same string as the original.
|
||||
assert_eq!(glob.glob(), glob_str);
|
||||
});
|
Reference in New Issue
Block a user