]> diplodocus.org Git - nmh/blob - test/format/test-functions
Remove unused NCWD and NPWD #defines.
[nmh] / test / format / test-functions
1 #!/bin/sh
2 #
3 # Test of various (well, start with one) function escapes.
4
5 set -e
6
7 if test -z "${MH_OBJ_DIR}"; then
8 srcdir=`dirname "$0"`/../..
9 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
10 fi
11
12 . "$MH_OBJ_DIR/test/common.sh"
13
14 setup_test
15 expected="$MH_TEST_DIR/test-functions$$.expected"
16 actual="$MH_TEST_DIR/test-functions$$.actual"
17
18 # check sday when day of week is specified
19 printf '1\n' >"$expected"
20 fmttest -raw -format '%(sday{text})' 'Fri Sep 12 20:02 2014' >"$actual"
21 check "$expected" "$actual"
22
23 # check sday when day of week is not specified
24 printf '0\n' >"$expected"
25 fmttest -raw -format '%(sday{text})' 'Sep 12 20:02 2014' >"$actual"
26 check "$expected" "$actual"
27
28 # check negative number, without padding
29 printf '%s\n' ' -42' >"$expected"
30 fmttest -raw -format '%4(minus -42)' 0 >"$actual"
31 check "$expected" "$actual"
32
33 # check negative number, with padding
34 # Output was "0-42" with nmh 1.6 and earlier.
35 printf '%s\n' -042 >"$expected"
36 fmttest -raw -format '%04(minus -42)' 0 >"$actual"
37 check "$expected" "$actual"
38
39 # check multiply
40 printf '%s\n' 42 >"$expected"
41 fmttest -raw -format '%(void(num 7))%(multiply 6)' 0 >"$actual"
42 check "$expected" "$actual"
43
44 exit $failed