1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

cp: add test for "cp always creates backup"

This commit is contained in:
Roy Ivy III 2018-09-22 19:10:14 -05:00 committed by Roy Ivy III
parent f0aecf4134
commit 332767e548

View file

@ -31,6 +31,23 @@ fn test_cp_cp() {
} }
#[test]
fn test_cp_existing_target() {
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_EXISTING_FILE)
.run();
assert!(result.success);
// Check the content of the destination file
assert_eq!(at.read(TEST_EXISTING_FILE), "Hello, World!\n");
// No backup should have been created
assert!(!at.file_exists(&*format!("{}~", TEST_EXISTING_FILE)));
}
#[test] #[test]
fn test_cp_duplicate_files() { fn test_cp_duplicate_files() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();