File: test-functions

package info (click to toggle)
nmh 1.8-4
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 7,860 kB
  • sloc: ansic: 50,445; sh: 22,697; makefile: 1,138; lex: 740; perl: 509; yacc: 265
file content (50 lines) | stat: -rwxr-xr-x 1,411 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
#
# Test of various (well, start with one) function escapes.

set -e

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname "$0"`/../..
    MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
fi

. "$MH_OBJ_DIR/test/common.sh"

setup_test
expected="$MH_TEST_DIR/test-functions$$.expected"
actual="$MH_TEST_DIR/test-functions$$.actual"

# check sday when day of week is specified
start_test "sday when day of week is specified"
printf '1\n' >"$expected"
fmttest -raw -format '%(sday{text})' 'Fri Sep 12 20:02 2014' >"$actual"
check "$expected" "$actual"

# check sday when day of week is not specified
start_test "sday when day of week is not specified"
printf '0\n' >"$expected"
fmttest -raw -format '%(sday{text})' 'Sep 12 20:02 2014' >"$actual"
check "$expected" "$actual"

# check negative number, without padding
start_test "negative number, without padding"
printf '%s\n' ' -42' >"$expected"
fmttest -raw -format '%4(minus -42)' 0 >"$actual"
check "$expected" "$actual"

# check negative number, with padding
start_test "negative number, with padding"
# Output was "0-42" with nmh 1.6 and earlier.
printf '%s\n' -042 >"$expected"
fmttest -raw -format '%04(minus -42)' 0 >"$actual"
check "$expected" "$actual"

# check multiply
start_test "multiply"
printf '%s\n' 42 >"$expected"
fmttest -raw -format '%(void(num 7))%(multiply 6)' 0 >"$actual"
check "$expected" "$actual"

finish_test
exit $failed