]>
diplodocus.org Git - nmh/blob - test/format/test-fmttest
3 # Tests for fmttest(1).
5 if test -z "${MH_OBJ_DIR}"; then
6 srcdir
=`dirname "$0"`/..
/..
7 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
10 .
"$MH_OBJ_DIR/test/common.sh"
14 # fmttest(1) doesn't accept `--' to mark the end of option processing.
15 # This is a bug. It also considers a string of `-3' to be an unknown
16 # option `3'; `-- -3' can't be used. One workaround is to give a
17 # string of `3' and use `%(void(minus 0))' in the format string to
18 # negate it, but this contains a space and makes parsing the here file
19 # tedious. Instead, pass the test value as the component `t', with a
20 # dummy string `unused' to satisfy the requirement of at least one thing
24 want_out
="$t.want.1" want_err
="$t.want.2"
25 got_out
="$t.got.1" got_err
="$t.got.2"
27 while read -r fmt val size out
; do
28 if test "$fmt" = '#'; then continue; fi
30 if test -n "$out"; then printf -- "$out\n"; fi >$want_out
33 fmttest
-raw -format "$fmt" -outsize "$size" \
34 --t "`printf -- $val`" unused
>$got_out 2>$got_err ||
37 label
="of \"$fmt\", size \"$size\", with \"$val\""
38 if test $r -ne 0; then
39 echo "$0: exit status $label is not 0: $r"
42 check
$want_out $got_out : "output $label" || ok
=false
43 check
$want_err $got_err : "errors $label" || ok
=false
46 # The `^' and `$' aren't used here as regexp meta-characters, but as
47 # bracketing characters around the escape that mnemonically stand for
48 # `before' and `after'. If parenthesis or similar are used then they
49 # trigger annoying behaviour in some editors.
51 # Test cpstripped() with FT_COMP.
82 # zputlit only outputs if there's room for following content.
83 # This suggests a zputlit to cancel the effect of an earlier zputlit may
85 ^
%(zputlit
{t
})%{t
}$ foo max ^foofoo$
86 ^
%(zputlit
{t
})%{t
}$ foo
5 ^foofoo$
87 ^
%(zputlit
{t
})%{t
}$ foo
4 ^foofoo
88 ^
%(zputlit
{t
})%{t
}$ foo
3 ^foofo
89 ^
%(zputlit
{t
})%{t
}$ foo
2 ^foof
90 ^
%(zputlit
{t
})%{t
}$ foo
1 ^
91 ^
%(zputlit
{t
})%{t
}$ foo
0
93 # Test leading whitespace is stripped, and intervening compressed.
96 %{t
} \t\
40f
\n\vo
\n\no
3 f o
97 %{t
} \t\
40f
\n\vo
\n\no
4 f o\
40
98 %{t
} \t\
40f
\n\vo
\n\no
5 f o o
100 # Test cptrimmed() with FT_COMPF.
101 %5{t
} dum max dum \
40
102 %5{t
} dumb max dumb\
40
103 %5{t
} dumbw max dumbw
104 %5{t
} dumbwa max dumbw
105 %5{t
} dumbwai max dumbw
106 %5{t
} dumbwai
6 dumbw
107 %5{t
} dumbwai
5 dumbw
109 ^
%5{t
} dum max ^dum \
40
110 ^
%5{t
} dumb max ^dumb\
40
111 ^
%5{t
} dumbw max ^dumbw
112 ^
%5{t
} dumbwa max ^dumbw
113 ^
%5{t
} dumbwai max ^dumbw
114 ^
%5{t
} dumbwai
6 ^dumbw
115 ^
%5{t
} dumbwai
5 ^dumb
116 ^
%5{t
} dumbwai
4 ^dum
118 %5{t
}$ dumb max dumb $
119 %5{t
}$ dumbw max dumbw$
120 %5{t
}$ dumbwa max dumbw$
121 %5{t
}$ dumbwai max dumbw$
122 %5{t
}$ dumbwai
7 dumbw$
123 %5{t
}$ dumbwai
6 dumbw$
124 %5{t
}$ dumbwai
5 dumbw
125 %5{t
}$ dumbwai
4 dumb
126 ^
%5{t
}$ dum max ^dum $
127 ^
%5{t
}$ dumb max ^dumb $
128 ^
%5{t
}$ dumbw max ^dumbw$
129 ^
%5{t
}$ dumbwa max ^dumbw$
130 ^
%5{t
}$ dumbwai max ^dumbw$
131 ^
%5{t
}$ dumbwai
8 ^dumbw$
132 ^
%5{t
}$ dumbwai
7 ^dumbw$
133 ^
%5{t
}$ dumbwai
6 ^dumbw
134 ^
%5{t
}$ dumbwai
5 ^dumb
136 %-5{t
} dum max \
40 dum
137 %-5{t
} dumb max \
40dumb
138 %-5{t
} dumbw max dumbw
139 %-5{t
} dumbwa max dumbw
140 %-5{t
} dumbwai max dumbw
141 %-5{t
} dumbwai
6 dumbw
142 %-5{t
} dumbwai
5 dumbw
143 %-5{t
} dumbwai
4 dumb
144 ^
%-5{t
} dum max ^ dum
145 ^
%-5{t
} dumb max ^ dumb
146 ^
%-5{t
} dumbw max ^dumbw
147 ^
%-5{t
} dumbwa max ^dumbw
148 ^
%-5{t
} dumbwai max ^dumbw
149 ^
%-5{t
} dumbwai
7 ^dumbw
150 ^
%-5{t
} dumbwai
6 ^dumbw
151 ^
%-5{t
} dumbwai
5 ^dumb
152 %-5{t
}$ dum max \
40 dum$
153 %-5{t
}$ dumb max \
40dumb$
154 %-5{t
}$ dumbw max dumbw$
155 %-5{t
}$ dumbwa max dumbw$
156 %-5{t
}$ dumbwai max dumbw$
157 %-5{t
}$ dumbwai
7 dumbw$
158 %-5{t
}$ dumbwai
6 dumbw$
159 %-5{t
}$ dumbwai
5 dumbw
160 %-5{t
}$ dumbwai
4 dumb
161 ^
%-5{t
}$ dum max ^ dum$
162 ^
%-5{t
}$ dumb max ^ dumb$
163 ^
%-5{t
}$ dumbw max ^dumbw$
164 ^
%-5{t
}$ dumbwa max ^dumbw$
165 ^
%-5{t
}$ dumbwai max ^dumbw$
166 ^
%-5{t
}$ dumbwai
8 ^dumbw$
167 ^
%-5{t
}$ dumbwai
7 ^dumbw$
168 ^
%-5{t
}$ dumbwai
6 ^dumbw
169 ^
%-5{t
}$ dumbwai
5 ^dumb
173 %(void
(compval
{t
}))%0(putnumf
) 3 max
174 %(void
(compval
{t
}))%1(putnumf
) 3 max
3
175 %(void
(compval
{t
}))%2(putnumf
) 3 max
\0403
176 %(void
(compval
{t
}))%3(putnumf
) 3 max
\040 3
177 %(void
(compval
{t
}))%00(putnumf
) 3 max
178 %(void
(compval
{t
}))%01(putnumf
) 3 max
3
179 %(void
(compval
{t
}))%02(putnumf
) 3 max
03
180 %(void
(compval
{t
}))%03(putnumf
) 3 max
003
181 %(void
(compval
{t
}))%-0(putnumf
) 3 max
182 %(void
(compval
{t
}))%-1(putnumf
) 3 max
3
183 %(void
(compval
{t
}))%-2(putnumf
) 3 max
3\
40
184 %(void
(compval
{t
}))%-3(putnumf
) 3 max
3 \
40
185 %(void
(compval
{t
}))%-00(putnumf
) 3 max
186 %(void
(compval
{t
}))%-01(putnumf
) 3 max
3
187 %(void
(compval
{t
}))%-02(putnumf
) 3 max
3\
40
188 %(void
(compval
{t
}))%-03(putnumf
) 3 max
3 \
40
190 %(void
(compval
{t
}))%0(putnumf
) -3 max
191 %(void
(compval
{t
}))%1(putnumf
) -3 max
192 %(void
(compval
{t
}))%2(putnumf
) -3 max
-3
193 %(void
(compval
{t
}))%3(putnumf
) -3 max
\040-3
194 %(void
(compval
{t
}))%4(putnumf
) -3 max
\040 -3
195 %(void
(compval
{t
}))%00(putnumf
) -3 max
196 %(void
(compval
{t
}))%01(putnumf
) -3 max
197 %(void
(compval
{t
}))%02(putnumf
) -3 max
-3
198 %(void
(compval
{t
}))%03(putnumf
) -3 max
-03
199 %(void
(compval
{t
}))%04(putnumf
) -3 max
-003
200 %(void
(compval
{t
}))%-0(putnumf
) -3 max
201 %(void
(compval
{t
}))%-1(putnumf
) -3 max
202 %(void
(compval
{t
}))%-2(putnumf
) -3 max
-3
203 %(void
(compval
{t
}))%-3(putnumf
) -3 max
-3\
40
204 %(void
(compval
{t
}))%-4(putnumf
) -3 max
-3 \
40
205 %(void
(compval
{t
}))%-00(putnumf
) -3 max
206 %(void
(compval
{t
}))%-01(putnumf
) -3 max
207 %(void
(compval
{t
}))%-02(putnumf
) -3 max
-3
208 %(void
(compval
{t
}))%-03(putnumf
) -3 max
-3\
40
209 %(void
(compval
{t
}))%-04(putnumf
) -3 max
-3 \
40
211 %(void
(compval
{t
}))%0(putnumf
) 42 max
212 %(void
(compval
{t
}))%1(putnumf
) 42 max ?
213 %(void
(compval
{t
}))%2(putnumf
) 42 max
42
214 %(void
(compval
{t
}))%3(putnumf
) 42 max
\04042
215 %(void
(compval
{t
}))%00(putnumf
) 42 max
216 %(void
(compval
{t
}))%01(putnumf
) 42 max ?
217 %(void
(compval
{t
}))%02(putnumf
) 42 max
42
218 %(void
(compval
{t
}))%03(putnumf
) 42 max
042
219 %(void
(compval
{t
}))%-0(putnumf
) 42 max
220 %(void
(compval
{t
}))%-1(putnumf
) 42 max ?
221 %(void
(compval
{t
}))%-2(putnumf
) 42 max
42
222 %(void
(compval
{t
}))%-3(putnumf
) 42 max
42\
40
223 %(void
(compval
{t
}))%-00(putnumf
) 42 max
224 %(void
(compval
{t
}))%-01(putnumf
) 42 max ?
225 %(void
(compval
{t
}))%-02(putnumf
) 42 max
42
226 %(void
(compval
{t
}))%-03(putnumf
) 42 max
42\
40
228 %(void
(compval
{t
}))%0(putnumf
) -42 max
229 %(void
(compval
{t
}))%1(putnumf
) -42 max
230 %(void
(compval
{t
}))%2(putnumf
) -42 max
-?
231 %(void
(compval
{t
}))%3(putnumf
) -42 max
-42
232 %(void
(compval
{t
}))%4(putnumf
) -42 max \
40-42
233 %(void
(compval
{t
}))%00(putnumf
) -42 max
234 %(void
(compval
{t
}))%01(putnumf
) -42 max
235 %(void
(compval
{t
}))%02(putnumf
) -42 max
-?
236 %(void
(compval
{t
}))%03(putnumf
) -42 max
-42
237 %(void
(compval
{t
}))%04(putnumf
) -42 max
-042
238 %(void
(compval
{t
}))%-0(putnumf
) -42 max
239 %(void
(compval
{t
}))%-1(putnumf
) -42 max
240 %(void
(compval
{t
}))%-2(putnumf
) -42 max
-?
241 %(void
(compval
{t
}))%-3(putnumf
) -42 max
-42
242 %(void
(compval
{t
}))%-4(putnumf
) -42 max
-42\
40
243 %(void
(compval
{t
}))%-00(putnumf
) -42 max
244 %(void
(compval
{t
}))%-01(putnumf
) -42 max
245 %(void
(compval
{t
}))%-02(putnumf
) -42 max
-?
246 %(void
(compval
{t
}))%-03(putnumf
) -42 max
-42
247 %(void
(compval
{t
}))%-04(putnumf
) -42 max
-42\
40
249 %(void
(compval
{t
}))%5(putnumf
) 13579 0
250 %(void
(compval
{t
}))%5(putnumf
) 13579 1
251 %(void
(compval
{t
}))%5(putnumf
) 13579 2
252 %(void
(compval
{t
}))%5(putnumf
) 13579 3
253 %(void
(compval
{t
}))%5(putnumf
) 13579 4
254 %(void
(compval
{t
}))%5(putnumf
) 13579 5 13579
255 %(void
(compval
{t
}))%5(putnumf
) 13579 6 13579
256 %(void
(compval
{t
}))%6(putnumf
) 13579 5
257 %(void
(compval
{t
}))%6(putnumf
) 13579 6 \04013579
258 %(void
(compval
{t
}))^
%5(putnumf
) 13579 0
259 %(void
(compval
{t
}))^
%5(putnumf
) 13579 1 ^
260 %(void
(compval
{t
}))^
%5(putnumf
) 13579 2 ^
261 %(void
(compval
{t
}))^
%5(putnumf
) 13579 3 ^
262 %(void
(compval
{t
}))^
%5(putnumf
) 13579 4 ^
263 %(void
(compval
{t
}))^
%5(putnumf
) 13579 5 ^
264 %(void
(compval
{t
}))^
%5(putnumf
) 13579 6 ^
13579
265 %(void
(compval
{t
}))^
%5(putnumf
) 13579 7 ^
13579
266 %(void
(compval
{t
}))^
%6(putnumf
) 13579 6 ^
267 %(void
(compval
{t
}))^
%6(putnumf
) 13579 7 ^
13579
268 %(void
(compval
{t
}))^
%6(putnumf
) 13579 8 ^
13579
269 %(void
(compval
{t
}))%5(putnumf
)$
13579 0
270 # FIXME: If output won't fit, stop; the `$' is wrong.
271 %(void
(compval
{t
}))%5(putnumf
)$
13579 1 $
272 %(void
(compval
{t
}))%5(putnumf
)$
13579 2 $
273 %(void
(compval
{t
}))%5(putnumf
)$
13579 3 $
274 %(void
(compval
{t
}))%5(putnumf
)$
13579 4 $
275 %(void
(compval
{t
}))%5(putnumf
)$
13579 5 13579
276 %(void
(compval
{t
}))%5(putnumf
)$
13579 6 13579$
277 %(void
(compval
{t
}))%5(putnumf
)$
13579 7 13579$
278 %(void
(compval
{t
}))%6(putnumf
)$
13579 5 $
279 %(void
(compval
{t
}))%6(putnumf
)$
13579 6 \04013579
280 %(void
(compval
{t
}))%6(putnumf
)$
13579 7 \04013579$
281 %(void
(compval
{t
}))%6(putnumf
)$
13579 8 \04013579$
282 %(void
(compval
{t
}))^
%5(putnumf
)$
13579 0
283 %(void
(compval
{t
}))^
%5(putnumf
)$
13579 1 ^
284 # FIXME: If output won't fit, stop; the `$' is wrong.
285 %(void
(compval
{t
}))^
%5(putnumf
)$
13579 2 ^$
286 %(void
(compval
{t
}))^
%5(putnumf
)$
13579 3 ^$
287 %(void
(compval
{t
}))^
%5(putnumf
)$
13579 4 ^$
288 %(void
(compval
{t
}))^
%5(putnumf
)$
13579 5 ^$
289 %(void
(compval
{t
}))^
%5(putnumf
)$
13579 6 ^
13579
290 %(void
(compval
{t
}))^
%5(putnumf
)$
13579 7 ^
13579$
291 %(void
(compval
{t
}))^
%5(putnumf
)$
13579 8 ^
13579$
292 %(void
(compval
{t
}))^
%6(putnumf
)$
13579 7 ^
\04013579
293 %(void
(compval
{t
}))^
%6(putnumf
)$
13579 8 ^
\04013579$
294 %(void
(compval
{t
}))^
%6(putnumf
)$
13579 9 ^
\04013579$