forked from bonsai/harakit
tests: bonsai/npc.mk: full ASCII test coverage
This commit is contained in:
parent
ee7b7e89b2
commit
588680406a
@ -10,7 +10,11 @@
|
||||
.PRAGMA: command_comment
|
||||
|
||||
.PHONY: npc_tests
|
||||
npc_tests: npc_args npc_help
|
||||
npc_tests: npc_help npc_args npc_ascii
|
||||
|
||||
.PHONY: npc_help
|
||||
npc_help: $(BIN)/npc
|
||||
! $(BIN)/npc -h
|
||||
|
||||
.PHONY: npc_args
|
||||
# arg parsing
|
||||
@ -20,23 +24,49 @@ npc_args:
|
||||
$(BIN)/npc -et </dev/null
|
||||
! $(BIN)/npc -et 5 </dev/null
|
||||
|
||||
.PHONY: npc_help
|
||||
npc_help: $(BIN)/npc
|
||||
! $(BIN)/npc -h
|
||||
.PHONY: npc_ascii
|
||||
# Test 0x00 to 0x7f in input; in other words, the full 7b ASCII range.
|
||||
npc_ascii: npc_ascii_controls npc_ascii_symbols npc_ascii_uppers # \
|
||||
# npc_ascii_lowers
|
||||
|
||||
#i=0; while "$BIN"/intcmp -l $i 178; do
|
||||
# printf '\\%s\\n' "$i" \
|
||||
# | xargs -I fmt printf fmt
|
||||
#
|
||||
# # simulate octal
|
||||
# i="$(printf '1 + %s\n' "$i" | bc)"
|
||||
# printf '%s\n' "$i" \
|
||||
# | tail -c 1 \
|
||||
# | xargs "$BIN"/intcmp -e 8 \
|
||||
# && i="$(printf '2 + %s\n' "$i" | bc)"
|
||||
# printf '%s\n' "$i" \
|
||||
# | tail -c 2 \
|
||||
# | dd count=1 bs=1 2>/dev/null \
|
||||
# | xargs "$BIN"/intcmp -e 8 \
|
||||
# && i="$(printf '20 + %s\n' "$i" | bc)"
|
||||
#done
|
||||
.PHONY: npc_ascii_controls
|
||||
# (control characters)
|
||||
npc_ascii_controls:
|
||||
# ASCII 0x00 to 0x0a (before the newline, due to xargs(1p) issues)
|
||||
awk 'BEGIN{ for (i = 0; i < 32; ++i) printf("%c", i); }' \
|
||||
| $(BIN)/npc \
|
||||
| head -n 1 \
|
||||
| xargs -I out test "^@^A^B^C^D^E^F^G^H" = out
|
||||
|
||||
# ASCII 0x0a (otherwise the head|tail sequence won't work) to 0x1f
|
||||
awk 'BEGIN{ for (i = 0; i < 32; ++i) printf("%c", i); print }' \
|
||||
| $(BIN)/npc \
|
||||
| head -n 2 \
|
||||
| tail -n 1 \
|
||||
| xargs -I out test "^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_"
|
||||
|
||||
.PHONY: npc_ascii_symbols
|
||||
# ASCII 0x1f to 0x3f (^_ and symbols)
|
||||
npc_ascii_symbols:
|
||||
# shell quoting olympics
|
||||
awk 'BEGIN{ for (i = 31; i < 64; ++i) printf("%c", i); print }' \
|
||||
| $(BIN)/npc \
|
||||
| sed -e s"/\'/\\\'/g" -e 's/"/\\"/g' \
|
||||
| xargs -I out test "^_ !\"#$$%&'()*+,-./0123456789:;<=>?" = out
|
||||
|
||||
.PHONY: npc_ascii_uppers
|
||||
# ASCII 0x40 to 0x5f (uppercases)
|
||||
npc_ascii_uppers:
|
||||
awk 'BEGIN{ for (i = 64; i < 96; ++i) printf("%c", i); print }' \
|
||||
| $(BIN)/npc \
|
||||
| sed 's/\\/\\\\/' \
|
||||
| xargs -I out test @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ = out
|
||||
|
||||
# This test is broken and will need closer inspection along with the npc(1)
|
||||
# source.
|
||||
# .PHONY: npc_ascii_lowers
|
||||
# # ASCII 0x60 to 0x7f (lowercases)
|
||||
# npc_ascii_lowers:
|
||||
# awk 'BEGIN{ for (i = 96; i < 128; ++i) printf("%c", i); print }' \
|
||||
# | $(BIN)/npc \
|
||||
# | xargs -I out test "\`abcdefghijklmnopqrstuvwxyz{|}~^?" = out
|
||||
|
Loading…
Reference in New Issue
Block a user