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

Merge pull request #7924 from cakebaker/split_reduce_duplication_in_test

split: use delegation to avoid code duplication in test
This commit is contained in:
Sylvestre Ledru 2025-05-12 12:02:10 +02:00 committed by GitHub
commit 8866ec3927
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,9 +17,7 @@ use std::{
};
use uutests::util::{AtPath, TestScenario};
use uutests::at_and_ucmd;
use uutests::new_ucmd;
use uutests::util_name;
use uutests::{at_and_ucmd, new_ucmd, util_name};
fn random_chars(n: usize) -> String {
rng()
@ -114,11 +112,7 @@ impl RandomFile {
/// Add n lines each of size `RandomFile::LINESIZE`
fn add_lines(&mut self, lines: usize) {
let mut n = lines;
while n > 0 {
writeln!(self.inner, "{}", random_chars(Self::LINESIZE)).unwrap();
n -= 1;
}
self.add_lines_with_line_size(lines, Self::LINESIZE);
}
/// Add n lines each of the given size.