Debian Codegraph @

texmf-dist/doc/latex/fifo-stack/fifo-stack-test.tex

raw
1 %%
2 %% This is file `fifo-stack-test.tex',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% fifo-stack.dtx (with options: `qstest')
8 %%
9 %% Copyright (C) 2014 Stephen Gaito (PerceptiSys Ltd)
10 %%
11 %% This work may be distributed and/or modified under the conditions of the LaTeX
12 %% Project Public License, either version 1.3 of this license or (at your
13 %% option) any later version.
14 %%
15 %% The latest version of this license is in http://www.latex-project.org/lppl.txt
16 %% and version 1.3 or later is part of all distributions of LaTeX version
17 %% 2005/12/01 or later.
18 %%
19 %% This work has the LPPL maintenance status `maintained'.
20 %%
21 %% The Current Maintainer of this work is Stephen Gaito.
22 %%
23 %% The released source can be found at:
24 %% https://github.com/diSimplex/latexFifoStack/tree/master/texStyle
25 %%
26 %% The development source can be found at:
27 %% https://github.com/stephengaito/latexFifoStack/tree/master/texStyle
28 %%
29 %% This work consists of the files fifo-stack.dtx, and fifo-stack.ins.
30 %%
31 %% The command:
32 %% pdflatex fifo-stack.ins
33 %% followed by:
34 %% pdflatex fifo-stack.dtx
35 %% will produce the derived files: fifo-stack.sty, fifo-stack-test.tex,
36 %% and fifo-stack.pdf.
37 %%
38 %% The command:
39 %% pdflatex fifo-stack-test.tex
40 %% will regression test the fifo-stack package. Output will be found in
41 %% fifo-stack-test.lgout. If pdflatex completes with no errors, then all
42 %% regression tests passed.
43 %%
44 \RequirePackage{qstest}
45 \RequirePackage{xifthen}
46 \IncludeTests{*}
47 \LogTests{lgout}{*}{*}
48 \RequirePackage{fifo-stack}
49 \begin{qstest}{Simple stack integration test}
50 {\FSCreate, \FSPush, \FSPop, \FSTop}
51
52 \FSCreate{testStack}{defaultValue}
53 \Expect*{\FSTop{testStack}}{defaultValue}
54 \FSPush{testStack}{firstValue}
55 \Expect*{\FSTop{testStack}}{firstValue}
56 \FSPush{testStack}{secondValue}
57 \Expect*{\FSTop{testStack}}{secondValue}
58 \FSPush{testStack}{thirdValue}
59 \Expect*{\FSTop{testStack}}{thirdValue}
60 \FSPop{testStack}
61 \Expect*{\FSTop{testStack}}{secondValue}
62 \FSPop{testStack}
63 \Expect*{\FSTop{testStack}}{firstValue}
64 \FSPop{testStack}
65 \Expect*{\FSTop{testStack}}{defaultValue}
66 \FSPop{testStack}
67 \Expect*{\FSTop{testStack}}{defaultValue}
68 \end{qstest}
69 \begin{qstest}{Up down up down stack integration test}
70 {\FSCreate, \FSPush, \FSPop, \FSTop}
71
72 \FSCreate{testStackUDUD}{defaultValue}
73 \Expect*{\FSTop{testStackUDUD}}{defaultValue}
74 \FSPush{testStackUDUD}{firstValue}
75 \Expect*{\FSTop{testStackUDUD}}{firstValue}
76 \FSPush{testStackUDUD}{secondValue}
77 \Expect*{\FSTop{testStackUDUD}}{secondValue}
78 \FSPop{testStackUDUD}
79 \Expect*{\FSTop{testStackUDUD}}{firstValue}
80 \FSPush{testStackUDUD}{newSecondValue}
81 \Expect*{\FSTop{testStackUDUD}}{newSecondValue}
82 \end{qstest}
83 \begin{qstest}{Simple FIFO integration test}
84 {\FSCreate, \FSPush, \FSShift, \FSTop, \FSBottom}
85
86 \FSCreate{testFifo}{defaultValue}
87 \Expect*{\FSTop{testFifo}}{defaultValue}
88 \Expect*{\FSBottom{testFifo}}{defaultValue}
89 \FSPush{testFifo}{firstValue}
90 \Expect*{\FSTop{testFifo}}{firstValue}
91 \Expect*{\FSBottom{testFifo}}{firstValue}
92 \FSPush{testFifo}{secondValue}
93 \Expect*{\FSTop{testFifo}}{secondValue}
94 \Expect*{\FSBottom{testFifo}}{firstValue}
95 \FSShift{testFifo}
96 \Expect*{\FSTop{testFifo}}{secondValue}
97 \Expect*{\FSBottom{testFifo}}{secondValue}
98 \FSPush{testFifo}{thirdValue}
99 \Expect*{\FSTop{testFifo}}{thirdValue}
100 \Expect*{\FSBottom{testFifo}}{secondValue}
101 \FSShift{testFifo}
102 \Expect*{\FSTop{testFifo}}{thirdValue}
103 \Expect*{\FSBottom{testFifo}}{thirdValue}
104 \FSShift{testFifo}
105 \Expect*{\FSTop{testFifo}}{defaultValue}
106 \Expect*{\FSBottom{testFifo}}{defaultValue}
107 \FSShift{testFifo}
108 \Expect*{\FSTop{testFifo}}{defaultValue}
109 \Expect*{\FSBottom{testFifo}}{defaultValue}
110 \end{qstest}
111 \begin{qstest}{Simple linear use of unshift/shift}
112 {\FSUnshift, \FSShift}
113
114 \FSCreate{testRStack}{defaultValue}
115 \Expect*{\FSBottom{testRStack}}{defaultValue}
116 \FSUnshift{testRStack}{firstValue}
117 \Expect*{\FSBottom{testRStack}}{firstValue}
118 \FSUnshift{testRStack}{secondValue}
119 \Expect*{\FSBottom{testRStack}}{secondValue}
120 \FSUnshift{testRStack}{thirdValue}
121 \Expect*{\FSBottom{testRStack}}{thirdValue}
122 \FSShift{testRStack}
123 \Expect*{\FSBottom{testRStack}}{secondValue}
124 \FSShift{testRStack}
125 \Expect*{\FSBottom{testRStack}}{firstValue}
126 \FSShift{testRStack}
127 \Expect*{\FSBottom{testRStack}}{defaultValue}
128 \FSShift{testRStack}
129 \Expect*{\FSBottom{testRStack}}{defaultValue}
130 \end{qstest}
131 \begin{qstest}{Full non-linear FIFO/stack integration test}
132 {\FSCreate, \FSPush, \FSPop, \FSUnshift, \FSShift, \FSTop, \FSBottom}
133
134 \FSCreate{testFS}{defaultValue}
135 \Expect*{\FSTop{testFS}}{defaultValue}
136 \Expect*{\FSBottom{testFS}}{defaultValue}
137 \FSPush{testFS}{value1}
138 \Expect*{\FSTop{testFS}}{value1}
139 \Expect*{\FSBottom{testFS}}{value1}
140 \FSUnshift{testFS}{value-1}
141 \Expect*{\FSTop{testFS}}{value1}
142 \Expect*{\FSBottom{testFS}}{value-1}
143 \FSShift{testFS}
144 \Expect*{\FSTop{testFS}}{value1}
145 \Expect*{\FSBottom{testFS}}{value1}
146 \FSPush{testFS}{value2}
147 \Expect*{\FSTop{testFS}}{value2}
148 \Expect*{\FSBottom{testFS}}{value1}
149 \FSUnshift{testFS}{value-1again}
150 \Expect*{\FSTop{testFS}}{value2}
151 \Expect*{\FSBottom{testFS}}{value-1again}
152 \FSUnshift{testFS}{value-2}
153 \Expect*{\FSTop{testFS}}{value2}
154 \Expect*{\FSBottom{testFS}}{value-2}
155 \FSPop{testFS}
156 \Expect*{\FSTop{testFS}}{value1}
157 \Expect*{\FSBottom{testFS}}{value-2}
158 \FSPop{testFS}
159 \Expect*{\FSTop{testFS}}{value-1again}
160 \Expect*{\FSBottom{testFS}}{value-2}
161 \FSShift{testFS}
162 \Expect*{\FSTop{testFS}}{value-1again}
163 \Expect*{\FSBottom{testFS}}{value-1again}
164 \FSPop{testFS}
165 \Expect*{\FSTop{testFS}}{defaultValue}
166 \Expect*{\FSBottom{testFS}}{defaultValue}
167 \FSPop{testFS}
168 \Expect*{\FSTop{testFS}}{defaultValue}
169 \Expect*{\FSBottom{testFS}}{defaultValue}
170 \FSShift{testFS}
171 \Expect*{\FSTop{testFS}}{defaultValue}
172 \Expect*{\FSBottom{testFS}}{defaultValue}
173 \end{qstest}
174 \begin{qstest}{FSClear, FSSize, and FSDestroy test}
175 {\FSCreate, \FSPush, \FSPop, \FSUnshift, \FSShift, \FSTop,
176 \FSBottom, \FSClear, \FSDestroy, \FSSize}
177
178 \FSCreate{testFSC}{defaultValue}
179 \Expect*{\FSSize{testFSC}}{0}
180 \Expect*{\FSTop{testFSC}}{defaultValue}
181 \Expect*{\FSBottom{testFSC}}{defaultValue}
182 \FSPush{testFSC}{value1}
183 \Expect*{\FSSize{testFSC}}{1}
184 \Expect*{\FSTop{testFSC}}{value1}
185 \Expect*{\FSBottom{testFSC}}{value1}
186 \FSUnshift{testFSC}{value-1}
187 \Expect*{\FSSize{testFSC}}{2}
188 \Expect*{\FSTop{testFSC}}{value1}
189 \Expect*{\FSBottom{testFSC}}{value-1}
190 \FSPush{testFSC}{value2}
191 \Expect*{\FSSize{testFSC}}{3}
192 \Expect*{\FSTop{testFSC}}{value2}
193 \Expect*{\FSBottom{testFSC}}{value-1}
194 \FSUnshift{testFSC}{value-2}
195 \Expect*{\FSSize{testFSC}}{4}
196 \Expect*{\FSTop{testFSC}}{value2}
197 \Expect*{\FSBottom{testFSC}}{value-2}
198 \FSClear{testFSC}
199 \Expect*{\FSSize{testFSC}}{0}
200 \Expect*{\FSTop{testFSC}}{defaultValue}
201 \Expect*{\FSBottom{testFSC}}{defaultValue}
202 \FSPush{testFSC}{value1}
203 \Expect*{\FSSize{testFSC}}{1}
204 \Expect*{\FSTop{testFSC}}{value1}
205 \Expect*{\FSBottom{testFSC}}{value1}
206 \FSUnshift{testFSC}{value-1}
207 \Expect*{\FSSize{testFSC}}{2}
208 \Expect*{\FSTop{testFSC}}{value1}
209 \Expect*{\FSBottom{testFSC}}{value-1}
210 \FSPush{testFSC}{value2}
211 \Expect*{\FSSize{testFSC}}{3}
212 \Expect*{\FSTop{testFSC}}{value2}
213 \Expect*{\FSBottom{testFSC}}{value-1}
214 \FSUnshift{testFSC}{value-2}
215 \Expect*{\FSSize{testFSC}}{4}
216 \Expect*{\FSTop{testFSC}}{value2}
217 \Expect*{\FSBottom{testFSC}}{value-2}
218 \FSDestroy{testFSC}
219 \end{qstest}
220 \begin{qstest}{Unit test of \fifo@stack@pointer}{\fifo@stack@pointer}
221 \makeatletter
222 \Expect*{\fifo@stack@pointer{1}}{ii}
223 \Expect*{\fifo@stack@pointer{0}}{i}
224 \Expect*{\fifo@stack@pointer{-1}}{@i}
225 \makeatother
226 \end{qstest}
227 \begin{qstest}{Unit test of \FSdestroy}
228 {\FSCreate, \FSDestroy}
229
230 \FSCreate{testFSDestroy}{defaultValue}
231 \makeatletter
232 \ExpectIfThen{\isnamedefined{testFSDestroy@fifo@stack@count@top}}
233 \ExpectIfThen{\isnamedefined{testFSDestroy@fifo@stack@count@bottom}}
234 \ExpectIfThen{\isnamedefined{testFSDestroy@fifo@stack@count@size}}
235 \ExpectIfThen{\isnamedefined{fifo@stack@top@testFSDestroy}}
236 \ExpectIfThen{\isnamedefined{fifo@stack@bottom@testFSDestroy}}
237 \makeatother
238 \FSDestroy{testFSDestroy}
239 \makeatletter
240 \ExpectIfThen{\isundefined\testFSDestroy@fifo@stack@count@top}
241 \ExpectIfThen{\isundefined\testFSDestroy@fifo@stack@count@bottom}
242 \ExpectIfThen{\isundefined\testFSDestroy@fifo@stack@count@size}
243 \ExpectIfThen{\isundefined\fifo@stack@top@testFSDestroy}
244 \ExpectIfThen{\isundefined\fifo@stack@bottom@testFSDestroy}
245 \makeatother
246 \end{qstest}
247 \begin{qstest}{Unit test of \FSPush and \FSTop}
248 {\FSCreate, \FSPush, \FSTop}
249
250 \FSCreate{testFSPush}{defaultValue}
251 \Expect*{\FSTop{testFSPush}}{defaultValue}
252 \FSPush{testFSPush}{\FSTop{testFSPush}-with-additional-text}
253 \Expect*{\FSTop{testFSPush}}{defaultValue-with-additional-text}
254 \end{qstest}
255 \begin{qstest}{Unit test of \FSUnshift and \FSBottom}
256 {\FSCreate, \FSUnshift, \FSBottom}
257
258 \FSCreate{testFSUnshift}{defaultValue}
259 \Expect*{\FSBottom{testFSUnshift}}{defaultValue}
260 \FSUnshift{testFSUnshift}{\FSBottom{testFSUnshift}-with-additional-text}
261 \Expect*{\FSBottom{testFSUnshift}}{defaultValue-with-additional-text}
262 \end{qstest}
263 \LogClose{lgout}
264 \stop
265 \endinput
266 %%
267 %% End of file `fifo-stack-test.tex'.