From 7c0499e2192aeb3a9ea1bc5ab8ea59a4fc876602 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Tue, 10 May 2022 23:22:39 +0200 Subject: [PATCH] Initial support for fuzzing --- fuzz/.gitignore | 3 +++ fuzz/Cargo.toml | 25 +++++++++++++++++++++ fuzz/fuzz_targets/hard_u128_to_f64_round.rs | 6 +++++ 3 files changed, 34 insertions(+) create mode 100644 fuzz/.gitignore create mode 100644 fuzz/Cargo.toml create mode 100644 fuzz/fuzz_targets/hard_u128_to_f64_round.rs diff --git a/fuzz/.gitignore b/fuzz/.gitignore new file mode 100644 index 0000000..a092511 --- /dev/null +++ b/fuzz/.gitignore @@ -0,0 +1,3 @@ +target +corpus +artifacts diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 0000000..b009efc --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "floatconv-fuzz" +version = "0.0.0" +authors = ["Automatically generated"] +publish = false +edition = "2018" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" + +[dependencies.floatconv] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +name = "hard_u128_to_f64_round" +path = "fuzz_targets/hard_u128_to_f64_round.rs" +test = false +doc = false diff --git a/fuzz/fuzz_targets/hard_u128_to_f64_round.rs b/fuzz/fuzz_targets/hard_u128_to_f64_round.rs new file mode 100644 index 0000000..c356f07 --- /dev/null +++ b/fuzz/fuzz_targets/hard_u128_to_f64_round.rs @@ -0,0 +1,6 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: u128| { + assert_eq!(floatconv::fast::u128_to_f64_round(data), data as f64); +});