]> diplodocus.org Git - nmh/blob - test/comp/test-comp-format
check_charset.c: Move interface to own file.
[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 check_exit '-eq 1' comp -
17 check_exit '-eq 1' comp -xyzzy
18 check_exit '-eq 0' comp -help
19 check_exit '-eq 0' comp -version
20 check_exit '-eq 1' comp -build -noedit -editor
21 check_exit '-eq 1' comp -whatnowproc
22 check_exit '-eq 1' comp -whatnowproc '' -
23 check_exit '-eq 1' comp -use -nouse -form
24 check_exit '-eq 1' comp -file
25 check_exit '-eq 1' comp -file foo -file
26 check_exit '-eq 1' comp -nodraftfolder -draftfolder
27 check_exit '-eq 1' comp -draftfolder foo -draftfolder
28 check_exit '-eq 1' comp -draftmessage
29 check_exit '-eq 1' comp -draftmessage foo -draftmessage
30 check_exit '-eq 1' comp -to
31 check_exit '-eq 1' comp -cc
32 check_exit '-eq 1' comp -from
33 check_exit '-eq 1' comp -fcc
34 check_exit '-eq 1' comp -fcc @ -
35 check_exit '-eq 1' comp -width
36 check_exit '-eq 1' comp -width 0
37 check_exit '-eq 1' comp -subject
38 check_exit '-eq 1' comp + @
39 check_exit '-eq 1' comp 42 314
40 check_exit '-eq 1' comp -form foo 42
41 check_exit '-eq 1' comp +
42 check_exit '-eq 1' comp 42
43
44 #
45 # Create a test template file (we create one here just in case the master
46 # one changes)
47 #
48
49 form="${MH_TEST_DIR}/$$.components"
50 cat > $form <<EOF
51 %(void{from})%(void(width))%(putaddr From: )
52 %(void{to})%(void(width))%(putaddr To: )
53 %(void{cc})%(void(width))%(putaddr cc: )
54 Fcc: %{fcc}
55 Subject: %{subject}
56 --------
57 EOF
58
59 expected="${MH_TEST_DIR}/$$.expected"
60 actual="${MH_TEST_DIR}/Mail/draft"
61 from="Mr Test User <test@example.com>"
62 to1="User One <userone@example.com>"
63 to2="User Two <usertwo@example.com>"
64 cc1="CC User One <ccuserone@example.com>"
65 cc2="CC User Two <ccusertwo@example.com>"
66 cc3="CC User Three <ccuserthree@example.com>"
67 cc4="CC User Four <ccuserfour@example.com>"
68 fcc1="+nosuchmailbox"
69 fcc2="+nosuchmailbox2"
70 subject="Totally bogus subject"
71
72 start_test 'check -from, -to, -cc, -fcc, and -subject switches'
73 cat > $expected <<EOF
74 From: ${from}
75 To: ${to1},
76 ${to2}
77 cc: ${cc1},
78 ${cc2},
79 ${cc3},
80 ${cc4}
81 Fcc: ${fcc1}, ${fcc2}
82 Subject: ${subject}
83 --------
84 EOF
85 run_prog \
86 comp -editor true -form "${form}" -from "${from}" -to "${to1}" -to "${to2}" \
87 -cc "${cc1}" -cc "${cc2}" -cc "${cc3}" -cc "${cc4}" -fcc "${fcc1}" \
88 -fcc "${fcc2}" -subject "${subject}" -width 60 -nowhatnowproc || exit 1
89 check "${expected}" "${actual}"
90
91
92 start_test 'check -fcc with no fcc in components'
93 cat > $form <<EOF
94 %<{from}%|%(void(localmbox))%>%(void(width))%(putaddr From: )
95 %<{to}%(void(width))%(putaddr To: )%|To:%>
96 %<{cc}%(void(width))%(putaddr cc: )%|cc:%>
97 Subject:%<{subject} %(putstr)%>
98 --------
99 EOF
100 #### There won't be an Fcc: header because there isn't one in the components.
101 cat > $expected <<EOF
102 From: ${from}
103 To: ${to1},
104 ${to2}
105 cc: ${cc1},
106 ${cc2},
107 ${cc3},
108 ${cc4}
109 Subject: ${subject}
110 --------
111 EOF
112
113 run_prog \
114 comp -editor true -form "${form}" -from "${from}" -to "${to1}" -to "${to2}" \
115 -cc "${cc1}" -cc "${cc2}" -cc "${cc3}" -cc "${cc4}" -fcc "${fcc1}" \
116 -fcc "${fcc2}" -subject "${subject}" -width 60 -nowhatnowproc || exit 1
117 check "${expected}" "${actual}"
118
119
120 test "${failed:-0}" -eq 0 && rm "${form}"
121
122 finish_test
123 exit $failed