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

od: enable hexadecimal output

This commit is contained in:
Wim Hueskes 2016-07-24 21:51:21 +02:00
parent e905c2ec71
commit 36b88f268d
2 changed files with 36 additions and 0 deletions

View file

@ -66,9 +66,13 @@ pub fn uumain(args: Vec<String>) -> i32 {
opts.optflag("I", "", "decimal 2-byte units"); opts.optflag("I", "", "decimal 2-byte units");
opts.optflag("L", "", "decimal 2-byte units"); opts.optflag("L", "", "decimal 2-byte units");
opts.optflag("i", "", "decimal 2-byte units"); opts.optflag("i", "", "decimal 2-byte units");
opts.optflag("x", "", "hexadecimal 2-byte units");
opts.optflag("h", "", "hexadecimal 2-byte units");
opts.optflag("O", "", "octal 4-byte units"); opts.optflag("O", "", "octal 4-byte units");
opts.optflag("s", "", "decimal 4-byte units"); opts.optflag("s", "", "decimal 4-byte units");
opts.optflag("X", "", "hexadecimal 4-byte units");
opts.optflag("H", "", "hexadecimal 4-byte units");
opts.optflag("e", "", "floating point double precision (64-bit) units"); opts.optflag("e", "", "floating point double precision (64-bit) units");
opts.optflag("f", "", "floating point single precision (32-bit) units"); opts.optflag("f", "", "floating point single precision (32-bit) units");

View file

@ -166,6 +166,38 @@ fn test_dec() {
} }
#[test]
fn test_hex16(){
let input : [u8; 9] = [
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xff];
let expected_output = unindent("
0000000 2301 6745 ab89 efcd 00ff
0000011
");
let result = new_ucmd!().arg("-x").run_piped_stdin(&input[..]);
assert_empty_stderr!(result);
assert!(result.success);
assert_eq!(result.stdout, expected_output);
}
#[test]
fn test_hex32(){
let input : [u8; 9] = [
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xff];
let expected_output = unindent("
0000000 67452301 efcdab89 000000ff
0000011
");
let result = new_ucmd!().arg("-X").run_piped_stdin(&input[..]);
assert_empty_stderr!(result);
assert!(result.success);
assert_eq!(result.stdout, expected_output);
}
#[test] #[test]
fn test_f32(){ fn test_f32(){