diff --git a/flatten-serde-json/fuzz/Cargo.toml b/flatten-serde-json/fuzz/Cargo.toml index 2e0510d5f..52b514785 100644 --- a/flatten-serde-json/fuzz/Cargo.toml +++ b/flatten-serde-json/fuzz/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "flatten_serde_json-fuzz" +name = "flatten-serde-json-fuzz" version = "0.0.0" authors = ["Automatically generated"] publish = false @@ -11,8 +11,9 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.4" arbitrary-json = "0.1.1" +json-depth-checker = { path = "../../json-depth-checker" } -[dependencies.flatten_serde_json] +[dependencies.flatten-serde-json] path = ".." # Prevent this from interfering with workspaces diff --git a/flatten-serde-json/fuzz/fuzz_targets/flatten.rs b/flatten-serde-json/fuzz/fuzz_targets/flatten.rs index 399d1c484..97969dfab 100644 --- a/flatten-serde-json/fuzz/fuzz_targets/flatten.rs +++ b/flatten-serde-json/fuzz/fuzz_targets/flatten.rs @@ -1,8 +1,12 @@ #![no_main] use arbitrary_json::ArbitraryObject; use flatten_serde_json::flatten; +use json_depth_checker::should_flatten_from_value; use libfuzzer_sys::fuzz_target; fuzz_target!(|object: ArbitraryObject| { - let _ = flatten(&object); + let object = flatten(&object); + if !object.is_empty() { + assert!(object.values().any(|value| !should_flatten_from_value(value))); + } });