-
Notifications
You must be signed in to change notification settings - Fork 50
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
Showing
4 changed files
with
51 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
target/ | ||
artifacts/ | ||
# This grows very quickly, and doesn't really need to be in-tree | ||
corpus/encoding_parse/ |
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 std::str::FromStr; | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
use objc2::encode::{Encoding, EncodingBox}; | ||
|
||
fuzz_target!(|s: &str| { | ||
// Check that parsing encodings doesn't panic | ||
if let Ok(enc) = EncodingBox::from_str(s) { | ||
// Check a "negative" case of `equivalent_to_box` | ||
if enc != EncodingBox::Char { | ||
assert_ne!(EncodingBox::Char, enc, "not equal to char"); | ||
assert!(!Encoding::Char.equivalent_to_box(&enc), "not equivalent to char"); | ||
} | ||
|
||
let s2 = enc.to_string(); | ||
// Note: s and s2 may not be equal! | ||
|
||
// Test roundtrip | ||
let enc2 = EncodingBox::from_str(&s2).expect("parsing valid encoding string"); | ||
let s3 = enc2.to_string(); | ||
assert_eq!(s2, s3); | ||
} | ||
}); |