@@@ adjust bench timings
[mLib] / test / tests.at
CommitLineData
b64eb60f
MW
1### -*-autotest-*-
2###
3### Test script for test machinery
4###
5### (c) 2023 Straylight/Edgeware
6###
7
8###----- Licensing notice ---------------------------------------------------
9###
10### This file is part of the mLib utilities library.
11###
12### mLib is free software; you can redistribute it and/or modify
13### it under the terms of the GNU Library General Public License as
14### published by the Free Software Foundation; either version 2 of the
15### License, or (at your option) any later version.
16###
17### mLib is distributed in the hope that it will be useful,
18### but WITHOUT ANY WARRANTY; without even the implied warranty of
19### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20### GNU Library General Public License for more details.
21###
22### You should have received a copy of the GNU Library General Public
23### License along with mLib; if not, write to the Free
24### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25### MA 02111-1307, USA.
26
27###--------------------------------------------------------------------------
28### tvec
29
30dnl test_filter(CMD, SED, RC, STDOUT, STDERR)
31m4_define([test_filter], [
32AT_CHECK([$1], [$3], [stdout-nolog], [stderr-nolog])
33##mv stdout rawout; mv stderr rawerr
34AT_CHECK([sed "AS_ESCAPE([$2])" stdout], [0], [$4])
35AT_CHECK([sed "AS_ESCAPE([$2])" stderr], [0], [$5])])
36
37dnl mismatch_filter
38m4_define([mismatch_filter],
39 [s/\(@%:@<@<:@0-9a-zA-Z_-@:>@*\) @<:@^>@:>@*>/\1 ...>/g])
40
41dnl test_parse(TY, IN, OUT)
42m4_define([test_parse], [
43AT_DATA([tv],
44[;;; -*-conf-*-
45[[$1]]
46$1 = $2
47@status = ?
48])
49test_filter([BUILDDIR/t/tvec.t -fh tv], [mismatch_filter], [1],
50[tv:3: `$1' FAILED
51 actual status = `.'
52 expected status = `?'
53 matched $1 = $3
54$1: 1/1 FAILED
55FAILED 1 out of 1 test in 1 out of 1 group
56])])
57
58dnl test_parserr(TY, IN, LNO, ERR)
59m4_define([test_parserr], [
60AT_DATA([tv],
61[;;; -*-conf-*-
62[[$1]]
63$1 = $2
64@status = ?
65])
66AT_CHECK([BUILDDIR/t/tvec.t -fh tv], [2], [],
67[tvec.t: tv:$3: $4
68])])
69
70AT_SETUP(tvec type-int)
71test_parse([int], [4], [4 ; = 0x04])
72test_parse([int], [ 17; comment], [17 ; = 0x11])
73test_parserr([int], [17 : badness], [3],
74 [syntax error: expected end-of-line but found `:'])
75test_parserr([int], [17: badness], [3],
76 [syntax error: expected end-of-line but found `:'])
77test_parse([int], [0x234], [564 ; = 0x0234])
78test_parse([int], [033], [27 ; = 0x1b])
79test_parse([int], [ +192], [192 ; = 0xc0])
80test_parse([int], [ -192], [-192 ; = -0xc0])
81test_parserr([int], [xyzzy], [3],
82 [syntax error: expected signed integer but found `x'])
83test_parserr([int], [-splat], [3],
84 [syntax error: expected signed integer but found `s'])
85test_parserr([int], [0xq], [3],
86 [syntax error: expected end-of-line but found `x'])
87test_parserr([int], [0x], [3],
88 [syntax error: expected end-of-line but found `x'])
89test_parserr([int], [], [3],
90 [syntax error: expected signed integer but found <eol>])
91test_parserr([int], [123456], [3],
92 [integer 123456 out of range (must be in [[-32768 .. 32767]])])
93AT_CLEANUP
94
95AT_SETUP(tvec type-uint)
96test_parse([uint], [4], [4 ; = 0x04])
97test_parse([uint], [ 17; comment], [17 ; = 0x11])
98test_parserr([uint], [17 : badness], [3],
99 [syntax error: expected end-of-line but found `:'])
100test_parserr([uint], [17: badness], [3],
101 [syntax error: expected end-of-line but found `:'])
102test_parse([uint], [0x234], [564 ; = 0x0234])
103test_parse([uint], [033], [27 ; = 0x1b])
104test_parserr([uint], [ +192], [3],
105 [syntax error: expected unsigned integer but found `+'])
106test_parserr([uint], [ -192], [3],
107 [syntax error: expected unsigned integer but found `-'])
108test_parserr([uint], [xyzzy], [3],
109 [syntax error: expected unsigned integer but found `x'])
110test_parserr([uint], [0xq], [3],
111 [syntax error: expected end-of-line but found `x'])
112test_parserr([uint], [0x], [3],
113 [syntax error: expected end-of-line but found `x'])
114test_parserr([uint], [], [3],
115 [syntax error: expected unsigned integer but found <eol>])
116test_parserr([uint], [123456], [3],
117 [integer 123456 out of range (must be in [[0 .. 65535]])])
118AT_CLEANUP
119
120AT_SETUP([tvec type-enum])
121test_parse([ienum], [less], [less ; = -1 = -0x01])
122test_parse([ienum], [+1], [greater ; = 1 = 0x01])
123test_parse([ienum], [17], [17 ; = 0x11])
124test_parse([uenum], [banana], [banana ; = 1 = 0x01])
125test_parse([uenum], [clementine], [clementine ; = 2 = 0x02])
126test_parse([uenum], [17], [17 ; = 0x11])
127test_parse([penum], [carol], [carol ; = @%:@<player ...>])
128test_parse([penum], [alice], [alice ; = @%:@<player ...>])
129test_parse([penum], [@%:@nil], [@%:@nil])
130AT_CLEANUP
131
132###----- That's all, folks --------------------------------------------------