Coverage Report

Created: 2025-08-26 06:48

/src/ryu/fuzz/fuzz_targets/fuzz_ryu.rs
Line
Count
Source
1
#![no_main]
2
3
use arbitrary::Arbitrary;
4
use libfuzzer_sys::fuzz_target;
5
use std::mem;
6
7
3.94k
#[derive(Arbitrary, Debug)]
<fuzz_ryu::FloatInput as arbitrary::Arbitrary>::arbitrary::{closure#0}
Line
Count
Source
7
1.96k
#[derive(Arbitrary, Debug)]
<fuzz_ryu::FloatInput as arbitrary::Arbitrary>::try_size_hint::{closure#0}
Line
Count
Source
7
1.98k
#[derive(Arbitrary, Debug)]
Unexecuted instantiation: <fuzz_ryu::FloatInput as arbitrary::Arbitrary>::arbitrary_take_rest::{closure#0}
8
enum FloatInput {
9
    F32(f32),
10
    F64(f64),
11
}
12
13
macro_rules! ryu_test {
14
    ($val:expr, $method:ident) => {
15
        match $val {
16
            val => {
17
                let mut buffer = ryu::Buffer::new();
18
                let string = buffer.$method(val);
19
                assert!(string.len() <= mem::size_of::<ryu::Buffer>());
20
                if val.is_finite() {
21
                    assert_eq!(val, string.parse().unwrap());
22
                }
23
            }
24
        }
25
    };
26
}
27
28
fuzz_target!(|inputs: (FloatInput, bool)| {
29
    let (input, finite) = inputs;
30
    match (input, finite) {
31
        (FloatInput::F32(val), false) => ryu_test!(val, format),
32
        (FloatInput::F32(val), true) => ryu_test!(val, format_finite),
33
        (FloatInput::F64(val), false) => ryu_test!(val, format),
34
        (FloatInput::F64(val), true) => ryu_test!(val, format_finite),
35
    }
36
});