/src/textwrap/fuzz/fuzz_targets/wrap_first_fit.rs
Line | Count | Source |
1 | | #![no_main] |
2 | | use arbitrary::Arbitrary; |
3 | | use libfuzzer_sys::fuzz_target; |
4 | | use textwrap::core; |
5 | | use textwrap::wrap_algorithms::wrap_first_fit; |
6 | | |
7 | | #[derive(Arbitrary, Debug, PartialEq)] |
8 | | struct Word { |
9 | | width: f64, |
10 | | whitespace_width: f64, |
11 | | penalty_width: f64, |
12 | | } |
13 | | |
14 | | #[rustfmt::skip] |
15 | | impl core::Fragment for Word { |
16 | 1.57M | fn width(&self) -> f64 { self.width } |
17 | 788k | fn whitespace_width(&self) -> f64 { self.whitespace_width } |
18 | 788k | fn penalty_width(&self) -> f64 { self.penalty_width } |
19 | | } |
20 | | |
21 | | fuzz_target!(|input: (f64, Vec<Word>)| { |
22 | | let width = input.0; |
23 | | let words = input.1; |
24 | | let _ = wrap_first_fit(&words, &[width]); |
25 | | }); |