]> diplodocus.org Git - nmh/blob - test/comp/test-comp-format
fgets() reserves space for the NUL itself.
[nmh] / test / comp / test-comp-format
1 #!/bin/sh
2 #
3 # Tests to see if the -from, -to, -cc, -fcc, and -subject switches to
4 # "comp" work correctly.
5 #
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
16 ! comp - >/dev/null 2>&1 # gcov
17
18 #
19 # Create a test template file (we create one here just in case the master
20 # one changes)
21 #
22
23 form="${MH_TEST_DIR}/$$.components"
24 cat > $form <<EOF
25 %(void{from})%(void(width))%(putaddr From: )
26 %(void{to})%(void(width))%(putaddr To: )
27 %(void{cc})%(void(width))%(putaddr cc: )
28 Fcc: %{fcc}
29 Subject: %{subject}
30 --------
31 EOF
32
33 expected="${MH_TEST_DIR}/$$.expected"
34 actual="${MH_TEST_DIR}/Mail/draft"
35 from="Mr Test User <test@example.com>"
36 to1="User One <userone@example.com>"
37 to2="User Two <usertwo@example.com>"
38 cc1="CC User One <ccuserone@example.com>"
39 cc2="CC User Two <ccusertwo@example.com>"
40 cc3="CC User Three <ccuserthree@example.com>"
41 cc4="CC User Four <ccuserfour@example.com>"
42 fcc1="+nosuchmailbox"
43 fcc2="+nosuchmailbox2"
44 subject="Totally bogus subject"
45
46 cat > $expected <<EOF
47 From: ${from}
48 To: ${to1},
49 ${to2}
50 cc: ${cc1},
51 ${cc2},
52 ${cc3},
53 ${cc4}
54 Fcc: ${fcc1}, ${fcc2}
55 Subject: ${subject}
56 --------
57 EOF
58
59 run_prog \
60 comp -editor true -form "${form}" -from "${from}" -to "${to1}" -to "${to2}" \
61 -cc "${cc1}" -cc "${cc2}" -cc "${cc3}" -cc "${cc4}" -fcc "${fcc1}" \
62 -fcc "${fcc2}" -subject "${subject}" -width 60 -nowhatnowproc || exit 1
63
64 check "${expected}" "${actual}"
65
66 test "${failed:-0}" -eq 0 && rm "${form}"
67
68 exit $failed