create the json-depth-checker crate

This commit is contained in:
Tamo 2022-04-11 18:43:44 +02:00 committed by Irevoire
parent 7791ef90e7
commit c2469b6765
No known key found for this signature in database
GPG key ID: 7A6A970C96104F1B
6 changed files with 230 additions and 1 deletions

View file

@ -0,0 +1,27 @@
[package]
name = "json-depth-checker"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"
arbitrary-json = "0.1.1"
serde_json = "1.0.79"
[dependencies.json-depth-checker]
path = ".."
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "depth"
path = "fuzz_targets/depth.rs"
test = false
doc = false

View file

@ -0,0 +1,13 @@
#![no_main]
use arbitrary_json::ArbitraryValue;
use json_depth_checker::*;
use libfuzzer_sys::fuzz_target;
fuzz_target!(|value: ArbitraryValue| {
let value = serde_json::Value::from(value);
let left = should_flatten_from_value(&value);
let value = serde_json::to_vec(&value).unwrap();
let right = should_flatten_from_unchecked_slice(&value);
assert_eq!(left, right);
});