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

Merge pull request #2136 from jaggededgedjustice/allow-truncate-size-and-reference

Allow truncate to take --size and --reference
This commit is contained in:
Sylvestre Ledru 2021-04-27 22:43:25 +02:00 committed by GitHub
commit 33139817a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 22 deletions

View file

@ -216,3 +216,16 @@ fn test_round_up() {
actual
);
}
#[test]
fn test_size_and_reference() {
let expected = 15;
let (at, mut ucmd) = at_and_ucmd!();
let mut file1 = at.make_file(TFILE1);
let mut file2 = at.make_file(TFILE2);
file1.write_all(b"1234567890").unwrap();
ucmd.args(&["--reference", TFILE1, "--size", "+5", TFILE2]).succeeds();
file2.seek(SeekFrom::End(0)).unwrap();
let actual = file2.seek(SeekFrom::Current(0)).unwrap();
assert!(expected == actual, "expected '{}' got '{}'", expected, actual);
}