mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
tests(truncate): Add more tests
This commit is contained in:
parent
ce66f3fbdb
commit
f888616c0b
1 changed files with 46 additions and 0 deletions
|
@ -14,6 +14,35 @@ fn test_increase_file_size() {
|
|||
assert!(file.seek(SeekFrom::Current(0)).unwrap() == 5 * 1024);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_increase_file_size_kb() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let mut file = at.make_file(TFILE1);
|
||||
ucmd.args(&["-s", "+5KB", TFILE1]).succeeds();
|
||||
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
assert!(file.seek(SeekFrom::Current(0)).unwrap() == 5 * 1000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_reference() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
let mut file = at.make_file(TFILE2);
|
||||
|
||||
scene.ucmd().arg("-s").arg("+5KB").arg(TFILE1).run();
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--reference")
|
||||
.arg(TFILE1)
|
||||
.arg(TFILE2)
|
||||
.run();
|
||||
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
assert!(file.seek(SeekFrom::Current(0)).unwrap() == 5 * 1000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_decrease_file_size() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
@ -23,3 +52,20 @@ fn test_decrease_file_size() {
|
|||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
assert!(file.seek(SeekFrom::Current(0)).unwrap() == 6);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_failed() {
|
||||
new_ucmd!().fails();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_failed_2() {
|
||||
let (_at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.args(&[TFILE1]).fails();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_failed_incorrect_arg() {
|
||||
let (_at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.args(&["-s", "+5A", TFILE1]).fails();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue