| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Tests for ap(8)'s coverage. |
| 4 |
|
| 5 |
if test -z "${MH_OBJ_DIR}"; then |
| 6 |
srcdir=`dirname "$0"`/../.. |
| 7 |
MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR |
| 8 |
fi |
| 9 |
|
| 10 |
. "$MH_OBJ_DIR/test/common.sh" |
| 11 |
|
| 12 |
setup_test |
| 13 |
|
| 14 |
# Use proper program, likely not the first one on PATH. |
| 15 |
ap="${MH_LIBEXEC_DIR}/ap" |
| 16 |
|
| 17 |
start_test 'ambiguous switch' |
| 18 |
check_exit '-eq 1' $ap - |
| 19 |
start_test 'invalid switch' |
| 20 |
check_exit '-eq 1' $ap -xyzzy |
| 21 |
start_test 'help' |
| 22 |
check_exit '-eq 0' $ap -help |
| 23 |
start_test 'version' |
| 24 |
check_exit '-eq 0' $ap -version |
| 25 |
start_test 'missing -form argument' |
| 26 |
check_exit '-eq 1' $ap -format foo -form |
| 27 |
start_test 'missing -format argument' |
| 28 |
check_exit '-eq 1' $ap -form foo -format |
| 29 |
start_test 'missing -width argument' |
| 30 |
check_exit '-eq 1' $ap -width |
| 31 |
x=tendixzehn |
| 32 |
l=$x$x$x$x$x |
| 33 |
c=$l$l |
| 34 |
start_test 'more than 100 addresses' |
| 35 |
check_exit '-eq 1' $ap `echo $c | sed 's/./ &/g'` 101 |
| 36 |
start_test 'no addresses' |
| 37 |
check_exit '-eq 1' $ap |
| 38 |
start_test 'success, though alias not found' |
| 39 |
COLUMNS=1 check_exit '-eq 0' $ap foo |
| 40 |
|
| 41 |
#### Make sure that 8-bit character is properly interpreted. |
| 42 |
require_locale $en_locales |
| 43 |
start_test 'address with 8-bit character' |
| 44 |
check_exit '-eq 1' $ap -width 0 `printf 'f\357o'` |
| 45 |
|
| 46 |
finish_test |