1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-08-04 21:52:54 +02:00
Files
ripgrep/fuzz/fuzz_targets/fuzz_glob.rs
William Johnson 95979048c9 globset: add opt-in Arbitrary trait implementations
This feature is mandatory when using `Glob` in fuzz testing.

Closes #2720
2025-07-26 10:42:28 -04:00

23 lines
509 B
Rust

#![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);
});