1
0
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:
William Johnson
2024-01-24 11:15:22 -05:00
committed by Andrew Gallant
parent 5548e538b1
commit 95979048c9
12 changed files with 358 additions and 1 deletions

View 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);
});