mirror of
https://github.com/ouch-org/ouch.git
synced 2025-07-29 14:12:49 +00:00
Actually fill dummy files with random data
This commit is contained in:
parent
308b8f7e90
commit
5775d4f268
@ -1,7 +1,7 @@
|
||||
use std::{io::Write, path::PathBuf};
|
||||
|
||||
use fs_err as fs;
|
||||
use rand::RngCore;
|
||||
use rand::{Rng, RngCore};
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! ouch {
|
||||
@ -15,9 +15,10 @@ macro_rules! ouch {
|
||||
|
||||
// write random content to a file
|
||||
pub fn write_random_content(file: &mut impl Write, rng: &mut impl RngCore) {
|
||||
let data = &mut Vec::with_capacity((rng.next_u32() % 8192) as usize);
|
||||
rng.fill_bytes(data);
|
||||
file.write_all(data).unwrap();
|
||||
let mut data = Vec::new();
|
||||
data.resize(rng.gen_range(0..8192), 0);
|
||||
rng.fill_bytes(&mut data);
|
||||
file.write_all(&data).unwrap();
|
||||
}
|
||||
|
||||
// check that two directories have the exact same content recursively
|
||||
|
Loading…
x
Reference in New Issue
Block a user