mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
tests ~ reorganize tests
This commit is contained in:
parent
1c88bc8c45
commit
de0375f909
75 changed files with 0 additions and 0 deletions
25
tests/by-util/test_truncate.rs
Normal file
25
tests/by-util/test_truncate.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use crate::common::util::*;
|
||||
use std::io::{Seek, SeekFrom, Write};
|
||||
|
||||
static TFILE1: &'static str = "truncate_test_1";
|
||||
static TFILE2: &'static str = "truncate_test_2";
|
||||
|
||||
#[test]
|
||||
fn test_increase_file_size() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let mut file = at.make_file(TFILE1);
|
||||
ucmd.args(&["-s", "+5K", TFILE1]).succeeds();
|
||||
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
assert!(file.seek(SeekFrom::Current(0)).unwrap() == 5 * 1024);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_decrease_file_size() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let mut file = at.make_file(TFILE2);
|
||||
file.write_all(b"1234567890").unwrap();
|
||||
ucmd.args(&["--size=-4", TFILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
assert!(file.seek(SeekFrom::Current(0)).unwrap() == 6);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue