Skip to content

Commit

Permalink
extend fuzzing to cover Display as well
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed May 25, 2021
1 parent f3bc45a commit bae08d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion fuzz/parse_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use std::str;

fuzz_target!(|bytes: &[u8]| {
if let Ok(string) = str::from_utf8(bytes) {
let _ = Version::parse(string);
if let Ok(v1) = Version::parse(string) {
let v2 = Version::parse(&v1.to_string()).unwrap();
assert_eq!(v1, v2);
}
}
});
5 changes: 4 additions & 1 deletion fuzz/parse_version_req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use std::str;

fuzz_target!(|bytes: &[u8]| {
if let Ok(string) = str::from_utf8(bytes) {
let _ = VersionReq::parse(string);
if let Ok(v1) = VersionReq::parse(string) {
let v2 = VersionReq::parse(&v1.to_string()).unwrap();
assert_eq!(v1, v2);
}
}
});

0 comments on commit bae08d4

Please sign in to comment.