aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-12-24 00:42:38 -0800
committerRob Landley <rob@landley.net>2017-12-26 22:28:10 -0600
commit215a6af5f83e7866751f24fc61f709b444e61c1d (patch)
treec1365d13267256e6fc1877ab3f238b6f5ac0ea32 /tests
parent70a6c55499eabf1229dfb0b49f08b366cbaa7896 (diff)
downloadtoybox-215a6af5f83e7866751f24fc61f709b444e61c1d.tar.gz
Add xxd -i (and xxd -ri).
The original xxd doesn't support -r with -i. The original also outputs "unsigned char name[] = { ... };" for input other than stdin, but that actually makes it less useful --- many languages support array initializers, but far fewer support that exact declaration syntax. Also fix the -c range checking and defaulting: ><= in the argument string only works for floating point arguments. Bug: http://b/64711851
Diffstat (limited to 'tests')
-rw-r--r--tests/xxd.test7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/xxd.test b/tests/xxd.test
index 5f43b8b5..97634e86 100644
--- a/tests/xxd.test
+++ b/tests/xxd.test
@@ -25,12 +25,15 @@ testing "-c 8 -g 4 file1" "xxd -c 8 -g 4 file1" \
testing "-c 8 -g 3 file1" "xxd -c 8 -g 3 file1" \
"00000000: 746869 732069 7320 this is \n00000008: 736f6d 652074 6578 some tex\n00000010: 740a t.\n" "" ""
+testing "-i" "cat file1 | xxd -i -" " 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x73, 0x6f, 0x6d, 0x65,\n 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a\n" "" ""
+
testing "-p" "xxd -p file1" "7468697320697320736f6d6520746578740a\n" "" ""
testing "-s" "xxd -s 13 file1" "0000000d: 7465 7874 0a text.\n" "" ""
-testing "-r" "xxd file1 | xxd -r" "this is some text\n" "" ""
-testing "-r -p" "xxd -p file1 | xxd -r -p" "this is some text\n" "" ""
+testing "-r" "echo -e ' 00000000: 7468 6973 2069 7320 736f 6d65 2074 6578 this is some tex\n00000010: 740a t.' | xxd -r" "this is some text\n" "" ""
+SKIP_HOST=1 testing "-r -i" "echo -e '0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x73, 0x6f, 0x6d, 0x65,\n 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a' | xxd -ri" "this is some text\n" "" ""
+testing "-r -p" "echo 7468697320697320736f6d6520746578740a | xxd -r -p" "this is some text\n" "" ""
testing "-r garbage" "echo '0000: 68 65 6c6c 6fxxxx' | xxd -r -" "hello" "" ""