Denys Vlasenko | dac5b83 | 2020-10-20 18:54:36 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Copyright 2020 by Denys Vlasenko <vda.linux@googlemail.com> |
| 4 | # Licensed under GPLv2, see file LICENSE in this source tree. |
| 5 | |
| 6 | . ./testing.sh |
| 7 | |
| 8 | # testing "description" "command" "result" "infile" "stdin" |
| 9 | testing 'xxd -p with one NUL' \ |
| 10 | 'xxd -p' \ |
| 11 | "\ |
| 12 | 00 |
| 13 | " \ |
| 14 | '' \ |
| 15 | '\0' |
| 16 | |
| 17 | testing 'xxd -p with 30 NULs' \ |
| 18 | 'xxd -p' \ |
| 19 | "\ |
| 20 | 000000000000000000000000000000000000000000000000000000000000 |
| 21 | " \ |
| 22 | '' \ |
| 23 | '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' |
| 24 | |
| 25 | testing 'xxd -p with 31 NULs' \ |
| 26 | 'xxd -p' \ |
| 27 | "\ |
| 28 | 000000000000000000000000000000000000000000000000000000000000 |
| 29 | 00 |
| 30 | " \ |
| 31 | '' \ |
| 32 | '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' |
| 33 | |
Denys Vlasenko | 86ba007 | 2021-10-08 23:03:54 +0200 | [diff] [blame] | 34 | testing 'xxd -p -r' \ |
| 35 | 'xxd -p -r' \ |
| 36 | '01234567765432100123456776543210' \ |
| 37 | '' \ |
| 38 | '30313233343536373736353433323130 30313233343536373736353433323130' |
| 39 | |
Denys Vlasenko | f318ada | 2022-08-22 15:40:47 +0200 | [diff] [blame] | 40 | testing 'xxd -r skips leading whitespace and truncates at two spaces' \ |
| 41 | 'xxd -r' \ |
| 42 | '0123456789:;<=>?@' \ |
Denys Vlasenko | 0011a6b | 2022-08-22 15:57:57 +0200 | [diff] [blame] | 43 | '' "\ |
Denys Vlasenko | f318ada | 2022-08-22 15:40:47 +0200 | [diff] [blame] | 44 | 00000000: 3031 3233 3435 3637 3839 3a3b 3c3d 3e3f 0123456789:;<=>? |
| 45 | 00000010: 40 @ |
| 46 | " |
| 47 | |
Denys Vlasenko | 0011a6b | 2022-08-22 15:57:57 +0200 | [diff] [blame] | 48 | testing 'xxd -p -r skips one bad char, truncates at two bad chars' \ |
| 49 | 'xxd -p -r' \ |
| 50 | '01' \ |
| 51 | '' "\ |
| 52 | 30 !31 !!32 |
| 53 | " |
| 54 | |
| 55 | testing 'xxd -p -r ignores the nibble with 2nd char bad' \ |
| 56 | 'xxd -p -r' \ |
| 57 | '3C6' \ |
| 58 | '' "\ |
| 59 | 33 3!4 3!!5 |
| 60 | 36 |
| 61 | " |
| 62 | |
Denys Vlasenko | dac5b83 | 2020-10-20 18:54:36 +0200 | [diff] [blame] | 63 | exit $FAILCOUNT |