-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
0ab4dd4
commit ad047bf
Showing
12 changed files
with
456 additions
and
55 deletions.
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,32 @@ | ||
#![no_main] | ||
|
||
use jiter::{Jiter, JiterError, JiterErrorType, JsonError, JsonValue}; | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
fn errors_equal(value_error: &JsonError, jiter_error: &JiterError) { | ||
let jiter_error_type = match &jiter_error.error_type { | ||
JiterErrorType::JsonError(json_error_type) => json_error_type, | ||
JiterErrorType::WrongType { .. } => panic!("Expected JsonError, found WrongType"), | ||
}; | ||
assert_eq!(&value_error.error_type, jiter_error_type); | ||
assert_eq!(value_error.index, jiter_error.index); | ||
} | ||
|
||
fuzz_target!(|json: String| { | ||
let json_data = json.as_bytes(); | ||
match JsonValue::parse(json_data, false) { | ||
Ok(_) => { | ||
let mut jiter = Jiter::new(json_data, false); | ||
jiter.next_skip().unwrap(); | ||
jiter.finish().unwrap(); | ||
} | ||
Err(json_error) => { | ||
let mut jiter = Jiter::new(json_data, false); | ||
let jiter_error = match jiter.next_skip() { | ||
Ok(_) => jiter.finish().unwrap_err(), | ||
Err(e) => e, | ||
}; | ||
errors_equal(&json_error, &jiter_error); | ||
} | ||
}; | ||
}); |
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
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
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
Oops, something went wrong.