1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

fuzz: also generate the empty string sometimes

Inspired by #6167, #6175, and the observation that 'echo hello "" world | hd' outputs extra spaces.
This commit is contained in:
Ben Wiederhake 2024-04-01 20:51:27 +02:00
parent cac7155fba
commit 58aab48ab2

View file

@ -374,7 +374,7 @@ pub fn generate_random_string(max_length: usize) -> String {
let invalid_utf8 = [0xC3, 0x28]; // Invalid UTF-8 sequence let invalid_utf8 = [0xC3, 0x28]; // Invalid UTF-8 sequence
let mut result = String::new(); 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) { if rng.gen_bool(0.9) {
let ch = valid_utf8.choose(&mut rng).unwrap(); let ch = valid_utf8.choose(&mut rng).unwrap();
result.push(*ch); result.push(*ch);