-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65e03a1
commit dde2b15
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![no_main] | ||
|
||
use batson::{batson_to_json_string, encode_from_json}; | ||
use jiter::JsonValue; | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
|
||
fn round_trip(json: String) { | ||
let Ok(jiter_value1) = JsonValue::parse(json.as_bytes(), false) else { | ||
return; | ||
}; | ||
let bytes1 = encode_from_json(&jiter_value1).unwrap(); | ||
let json1 = batson_to_json_string(&bytes1).unwrap(); | ||
|
||
let jiter_value2 = JsonValue::parse(json1.as_bytes(), false).unwrap(); | ||
let bytes2 = encode_from_json(&jiter_value2).unwrap(); | ||
let json2 = batson_to_json_string(&bytes2).unwrap(); | ||
|
||
assert_eq!(json1, json2); | ||
} | ||
|
||
fuzz_target!(|json: String| { | ||
round_trip(json); | ||
}); |