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