Skip to content

Commit

Permalink
fuzz: also generate the empty string sometimes
Browse files Browse the repository at this point in the history
Inspired by uutils#6167, uutils#6175, and the observation that 'echo hello "" world | hd' outputs extra spaces.
  • Loading branch information
BenWiederhake committed Apr 1, 2024
1 parent cac7155 commit 58aab48
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/fuzz_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ pub fn generate_random_string(max_length: usize) -> String {
let invalid_utf8 = [0xC3, 0x28]; // Invalid UTF-8 sequence
let mut result = String::new();

for _ in 0..rng.gen_range(1..=max_length) {
for _ in 0..rng.gen_range(0..=max_length) {
if rng.gen_bool(0.9) {
let ch = valid_utf8.choose(&mut rng).unwrap();
result.push(*ch);
Expand Down

0 comments on commit 58aab48

Please sign in to comment.