mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
od: implement -w (width)
This commit is contained in:
parent
1b01f02e9e
commit
167d7d3ca9
4 changed files with 78 additions and 8 deletions
|
@ -223,3 +223,54 @@ fn mit_die_umlauten_getesten() {
|
|||
"0000000 U n i v e r s i t ä ** t T ü **\n0000020 b i n g e n\n0000026")
|
||||
}
|
||||
*/
|
||||
|
||||
#[test]
|
||||
fn test_width(){
|
||||
|
||||
let input : [u8; 8] = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
|
||||
let expected_output = unindent("
|
||||
0000000 000000 000000
|
||||
0000004 000000 000000
|
||||
0000010
|
||||
");
|
||||
|
||||
let result = new_ucmd!().arg("-w4").run_piped_stdin(&input[..]);
|
||||
|
||||
assert_empty_stderr!(result);
|
||||
assert!(result.success);
|
||||
assert_eq!(result.stdout, expected_output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_width(){
|
||||
|
||||
let input : [u8; 4] = [0x00, 0x00, 0x00, 0x00];
|
||||
let expected_output = unindent("
|
||||
0000000 000000
|
||||
0000002 000000
|
||||
0000004
|
||||
");
|
||||
|
||||
let result = new_ucmd!().arg("-w5").run_piped_stdin(&input[..]);
|
||||
|
||||
assert_eq!(result.stderr, "od: warning: invalid width 5; using 2 instead\n");
|
||||
assert!(result.success);
|
||||
assert_eq!(result.stdout, expected_output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_width_without_value(){
|
||||
|
||||
let input : [u8; 40] = [0 ; 40];
|
||||
let expected_output = unindent("
|
||||
0000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
|
||||
0000040 000000 000000 000000 000000
|
||||
0000050
|
||||
");
|
||||
|
||||
let result = new_ucmd!().arg("-w").run_piped_stdin(&input[..]);
|
||||
|
||||
assert_empty_stderr!(result);
|
||||
assert!(result.success);
|
||||
assert_eq!(result.stdout, expected_output);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue