%%
%% This is file `intcalc-test3.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% intcalc.dtx  (with options: `test2,noetex')
%% 
%% This is a generated file.
%% 
%% Project: intcalc
%% Version: 2007/09/27 v1.1
%% 
%% Copyright (C) 2007 by
%%    Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and 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".
%% 
%% This Current Maintainer of this work is Heiko Oberdiek.
%% 
%% The Base Interpreter refers to any `TeX-Format',
%% because some files are installed in TDS:tex/generic//.
%% 
%% This work consists of the main source file intcalc.dtx
%% and the derived files
%%    intcalc.sty, intcalc.pdf, intcalc.ins, intcalc.drv,
%%    intcalc-test1.tex, intcalc-test2.tex, intcalc-test3.tex,
%%    intcalc-test4.tex.
%% 
\NeedsTeXFormat{LaTeX2e}
\nofiles
\documentclass{article}
\let\SavedNumexpr\numexpr
\let\numexpr\UNDEFINED
\makeatletter
\chardef\InCa@TestMode=1 %
\makeatother
\usepackage{intcalc}[2007/09/27]
\let\numexpr\SavedNumexpr
\usepackage{qstest}
\IncludeTests{*}
\LogTests{log}{*}{*}
\newcommand*{\TestSpaceAtEnd}[1]{%
  \let\SavedNumexpr\numexpr
  \let\numexpr\UNDEFINED
  \edef\resultA{#1}%
  \edef\resultB{#1 }%
  \let\numexpr\SavedNumexpr
  \Expect*{\resultA\space}*{\resultB}%
}
\newcommand*{\TestResult}[2]{%
  \let\SavedNumexpr\numexpr
  \let\numexpr\UNDEFINED
  \edef\result{#1}%
  \let\numexpr\SavedNumexpr
  \Expect*{\result}{#2}%
}
\newcommand*{\TestResultTwoExpansions}[2]{%
  \begingroup
    \let\numexpr\UNDEFINED
    \expandafter\expandafter\expandafter
  \endgroup
  \expandafter\expandafter\expandafter\Expect
  \expandafter\expandafter\expandafter{#1}{#2}%
}
\newcount\TestCount
\newcommand*{\TestArg}[1]{#1}
\newcommand*{\TestTeXDivide}[2]{%
  \TestCount=\TestArg{#1}\relax
  \divide\TestCount by \TestArg{#2}\relax
  \Expect*{\intcalcDiv{#1}{#2}}*{\the\TestCount}%
}
\newcommand*{\Test}[2]{%
  \TestResult{#1}{#2}%
  \TestResultTwoExpansions{#1}{#2}%
  \TestSpaceAtEnd{#1}%
}
\newcommand*{\TestExch}[2]{\Test{#2}{#1}}
\newcommand*{\TestInv}[2]{%
  \Test{\intcalcInv{#1}}{#2}%
}
\newcommand*{\TestNum}[2]{%
  \Test{\intcalcNum{#1}}{#2}%
}
\newcommand*{\TestAbs}[2]{%
  \Test{\intcalcAbs{#1}}{#2}%
}
\newcommand*{\TestSgn}[2]{%
  \Test{\intcalcSgn{#1}}{#2}%
}
\newcommand*{\TestMin}[3]{%
  \Test{\intcalcMin{#1}{#2}}{#3}%
}
\newcommand*{\TestMax}[3]{%
  \Test{\intcalcMax{#1}{#2}}{#3}%
}
\newcommand*{\TestCmp}[3]{%
  \Test{\intcalcCmp{#1}{#2}}{#3}%
}
\newcommand*{\TestInc}[2]{%
  \Test{\intcalcInc{#1}}{#2}%
  \ifnum\intcalcNum{#1}>-1 %
    \edef\x{%
      \noexpand\Test{%
        \noexpand\IntCalcInc\intcalcNum{#1}!%
      }{#2}%
    }%
    \x
  \fi
}
\newcommand*{\TestDec}[2]{%
  \Test{\intcalcDec{#1}}{#2}%
  \ifnum\intcalcNum{#1}>0 %
    \edef\x{%
      \noexpand\Test{%
        \noexpand\IntCalcDec\intcalcNum{#1}!%
      }{#2}%
    }%
    \x
  \fi
}
\newcommand*{\TestAdd}[3]{%
  \Test{\intcalcAdd{#1}{#2}}{#3}%
  \ifnum\intcalcNum{#1}>0 %
    \ifnum\intcalcNum{#2}> 0 %
      \ifnum\intcalcCmp{#1}{#2}>0 %
        \edef\x{%
          \noexpand\Test{%
            \noexpand\IntCalcAdd
            \intcalcNum{#1}!\intcalcNum{#2}!%
          }{#3}%
        }%
        \x
      \else
        \edef\x{%
          \noexpand\Test{%
            \noexpand\IntCalcAdd
            \intcalcNum{#2}!\intcalcNum{#1}!%
          }{#3}%
        }%
        \x
      \fi
    \fi
  \fi
}
\newcommand*{\TestSub}[3]{%
  \Test{\intcalcSub{#1}{#2}}{#3}%
  \ifnum\intcalcNum{#1}>0 %
    \ifnum\intcalcNum{#2}> 0 %
      \ifnum\intcalcCmp{#1}{#2}>0 %
        \edef\x{%
          \noexpand\Test{%
            \noexpand\IntCalcSub
            \intcalcNum{#1}!\intcalcNum{#2}!%
          }{#3}%
        }%
        \x
      \fi
    \fi
  \fi
}
\newcommand*{\TestShl}[2]{%
  \Test{\intcalcShl{#1}}{#2}%
  \edef\x{%
    \noexpand\Test{%
      \noexpand\IntCalcShl\intcalcAbs{#1}!%
    }{\intcalcAbs{#2}}%
  }%
  \x
}
\newcommand*{\TestShr}[2]{%
  \Test{\intcalcShr{#1}}{#2}%
  \edef\x{%
    \noexpand\Test{%
      \noexpand\IntCalcShr\intcalcAbs{#1}!%
    }{\intcalcAbs{#2}}%
  }%
  \x
}
\newcommand*{\TestMul}[3]{%
  \Test{\intcalcMul{#1}{#2}}{#3}%
  \edef\x{%
    \noexpand\Test{%
      \noexpand\IntCalcMul\intcalcAbs{#1}!\intcalcAbs{#2}!%
    }{\intcalcAbs{#3}}%
  }%
  \x
}
\newcommand*{\TestSqr}[2]{%
  \Test{\intcalcSqr{#1}}{#2}%
}
\newcommand*{\TestFac}[2]{%
  \expandafter\TestExch\expandafter{\the\numexpr#2}{\intcalcFac{#1}}%
}
\newcommand*{\TestPow}[3]{%
  \Test{\intcalcPow{#1}{#2}}{#3}%
}
\newcommand*{\TestDiv}[3]{%
  \Test{\intcalcDiv{#1}{#2}}{#3}%
  \TestTeXDivide{#1}{#2}%
  \edef\x{%
    \noexpand\Test{%
      \noexpand\IntCalcDiv\intcalcAbs{#1}!\intcalcAbs{#2}!%
    }{\intcalcAbs{#3}}%
  }%
}
\newcommand*{\TestMod}[3]{%
  \Test{\intcalcMod{#1}{#2}}{#3}%
  \ifcase\ifcase\intcalcSgn{#1} 0%
         \or
           \ifcase\intcalcSgn{#2} 1%
           \or 0%
           \else 1%
           \fi
         \else
           \ifcase\intcalcSgn{#2} 1%
           \or 1%
           \else 0%
           \fi
         \fi\relax
    \edef\x{%
      \noexpand\Test{%
        \noexpand\IntCalcMod
        \intcalcAbs{#1}!\intcalcAbs{#2}!%
      }{\intcalcAbs{#3}}%
    }%
    \x
  \fi
}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdfresettimer\endcsname\relax
\else
  \makeatletter
  \newcount\SummaryTime
  \newcount\TestTime
  \SummaryTime=\z@
  \newcommand*{\PrintTime}[2]{%
    \typeout{%
      [Time #1: \strip@pt\dimexpr\number#2sp\relax\space s]%
    }%
  }%
  \newcommand*{\StartTime}[1]{%
    \renewcommand*{\TimeDescription}{#1}%
    \pdfresettimer
  }%
  \newcommand*{\TimeDescription}{}%
  \newcommand*{\StopTime}{%
    \TestTime=\pdfelapsedtime
    \global\advance\SummaryTime\TestTime
    \PrintTime\TimeDescription\TestTime
  }%
  \let\saved@qstest\qstest
  \let\saved@endqstest\endqstest
  \def\qstest#1#2{%
    \saved@qstest{#1}{#2}%
    \StartTime{#1}%
  }%
  \def\endqstest{%
    \StopTime
    \saved@endqstest
  }%
  \AtEndDocument{%
    \PrintTime{summary}\SummaryTime
  }%
  \makeatother
\fi
\makeatletter

\begin{qstest}{num}{num}%
  \TestNum{0}{0}%
  \TestNum{1}{1}%
  \TestNum{-1}{-1}%
  \TestNum{10}{10}%
  \TestNum{-10}{-10}%
  \TestNum{2147483647}{2147483647}%
  \TestNum{-2147483647}{-2147483647}%
  \TestNum{ 0 }{0}%
  \TestNum{ 1 }{1}%
  \TestNum{--1}{1}%
  \TestNum{ - + - + 4 }{4}%
  \TestNum{\z@}{0}%
  \TestNum{\@ne}{1}%
  \TestNum{\m@ne}{-1}%
\end{qstest}

\begin{qstest}{inv}{inv}%
  \TestInv{0}{0}%
  \TestInv{1}{-1}%
  \TestInv{-1}{1}%
  \TestInv{10}{-10}%
  \TestInv{-10}{10}%
  \TestInv{2147483647}{-2147483647}%
  \TestInv{-2147483647}{2147483647}%
  \TestInv{ 0 }{0}%
  \TestInv{ 1 }{-1}%
  \TestInv{--1}{-1}%
  \TestInv{\z@}{0}%
  \TestInv{\@ne}{-1}%
  \TestInv{\m@ne}{1}%
\end{qstest}

\begin{qstest}{abs}{abs}%
  \TestAbs{0}{0}%
  \TestAbs{1}{1}%
  \TestAbs{-1}{1}%
  \TestAbs{10}{10}%
  \TestAbs{-10}{10}%
  \TestAbs{2147483647}{2147483647}%
  \TestAbs{-2147483647}{2147483647}%
  \TestAbs{ 0 }{0}%
  \TestAbs{ 1 }{1}%
  \TestAbs{--1}{1}%
  \TestAbs{\z@}{0}%
  \TestAbs{\@ne}{1}%
  \TestAbs{\m@ne}{1}%
\end{qstest}

\begin{qstest}{sign}{sign}%
  \TestSgn{0}{0}%
  \TestSgn{1}{1}%
  \TestSgn{-1}{-1}%
  \TestSgn{10}{1}%
  \TestSgn{-10}{-1}%
  \TestSgn{2147483647}{1}%
  \TestSgn{-2147483647}{-1}%
  \TestSgn{ 0 }{0}%
  \TestSgn{ 2 }{1}%
  \TestSgn{ -2 }{-1}%
  \TestSgn{--2}{1}%
  \TestSgn{\z@}{0}%
  \TestSgn{\@ne}{1}%
  \TestSgn{\m@ne}{-1}%
\end{qstest}

\begin{qstest}{min}{min}%
  \TestMin{0}{1}{0}%
  \TestMin{1}{0}{0}%
  \TestMin{-10}{-20}{-20}%
  \TestMin{ 1 }{ 2 }{1}%
  \TestMin{ 2 }{ 1 }{1}%
  \TestMin{1}{1}{1}%
  \TestMin{\z@}{\@ne}{0}%
  \TestMin{\@ne}{\m@ne}{-1}%
\end{qstest}

\begin{qstest}{max}{max}%
  \TestMax{0}{1}{1}%
  \TestMax{1}{0}{1}%
  \TestMax{-10}{-20}{-10}%
  \TestMax{ 1 }{ 2 }{2}%
  \TestMax{ 2 }{ 1 }{2}%
  \TestMax{1}{1}{1}%
  \TestMax{\z@}{\@ne}{1}%
  \TestMax{\@ne}{\m@ne}{1}%
\end{qstest}

\begin{qstest}{cmp}{cmp}%
  \TestCmp{0}{0}{0}%
  \TestCmp{-21}{17}{-1}%
  \TestCmp{3}{4}{-1}%
  \TestCmp{-10}{-10}{0}%
  \TestCmp{-10}{-11}{1}%
  \TestCmp{100}{5}{1}%
  \TestCmp{2147483647}{-2147483647}{1}%
  \TestCmp{-2147483647}{2147483647}{-1}%
  \TestCmp{2147483647}{2147483647}{0}%
  \TestCmp{\z@}{\@ne}{-1}%
  \TestCmp{\@ne}{\m@ne}{1}%
  \TestCmp{ 4 }{ 5 }{-1}%
  \TestCmp{ -3 }{ -7 }{1}%
\end{qstest}

\begin{qstest}{fac}{fac}
  \TestFac{0}{1}%
  \TestFac{1}{1}%
  \TestFac{2}{2}%
  \TestFac{3}{2*3}%
  \TestFac{4}{2*3*4}%
  \TestFac{5}{2*3*4*5}%
  \TestFac{6}{2*3*4*5*6}%
  \TestFac{7}{2*3*4*5*6*7}%
  \TestFac{8}{2*3*4*5*6*7*8}%
  \TestFac{9}{2*3*4*5*6*7*8*9}%
  \TestFac{10}{2*3*4*5*6*7*8*9*10}%
  \TestFac{11}{2*3*4*5*6*7*8*9*10*11}%
  \TestFac{12}{2*3*4*5*6*7*8*9*10*11*12}%
\end{qstest}

\begin{qstest}{inc}{inc}%
  \TestInc{0}{1}%
  \TestInc{1}{2}%
  \TestInc{-1}{0}%
  \TestInc{10}{11}%
  \TestInc{-10}{-9}%
  \TestInc{999}{1000}%
  \TestInc{-1000}{-999}%
  \TestInc{129}{130}%
  \TestInc{2147483646}{2147483647}%
  \TestInc{-2147483647}{-2147483646}%
\end{qstest}

\begin{qstest}{dec}{dec}%
  \TestDec{0}{-1}%
  \TestDec{1}{0}%
  \TestDec{-1}{-2}%
  \TestDec{10}{9}%
  \TestDec{-10}{-11}%
  \TestDec{1000}{999}%
  \TestDec{-999}{-1000}%
  \TestDec{130}{129}%
  \TestDec{2147483647}{2147483646}%
  \TestDec{-2147483646}{-2147483647}%
\end{qstest}

\begin{qstest}{add}{add}%
  \TestAdd{0}{0}{0}%
  \TestAdd{1}{0}{1}%
  \TestAdd{0}{1}{1}%
  \TestAdd{1}{2}{3}%
  \TestAdd{-1}{-1}{-2}%
  \TestAdd{2147483646}{1}{2147483647}%
  \TestAdd{-2147483647}{2147483647}{0}%
  \TestAdd{20}{-5}{15}%
  \TestAdd{-4}{-1}{-5}%
  \TestAdd{-1}{-4}{-5}%
  \TestAdd{-4}{1}{-3}%
  \TestAdd{-1}{4}{3}%
  \TestAdd{4}{-1}{3}%
  \TestAdd{1}{-4}{-3}%
  \TestAdd{-4}{-1}{-5}%
  \TestAdd{-1}{-4}{-5}%
  \TestAdd{ -4 }{ -1 }{-5}%
  \TestAdd{ -1 }{ -4 }{-5}%
  \TestAdd{ -4 }{ 1 }{-3}%
  \TestAdd{ -1 }{ 4 }{3}%
  \TestAdd{ 4 }{ -1 }{3}%
  \TestAdd{ 1 }{ -4 }{-3}%
  \TestAdd{ -4 }{ -1 }{-5}%
  \TestAdd{ -1 }{ -4 }{-5}%
  \TestAdd{876543210}{111111111}{987654321}%
  \TestAdd{999999999}{2}{1000000001}%
\end{qstest}

\begin{qstest}{sub}{sub}
  \TestSub{0}{0}{0}%
  \TestSub{1}{0}{1}%
  \TestSub{1}{2}{-1}%
  \TestSub{-1}{-1}{0}%
  \TestSub{2147483646}{-1}{2147483647}%
  \TestSub{-2147483647}{-2147483647}{0}%
  \TestSub{-4}{-1}{-3}%
  \TestSub{-1}{-4}{3}%
  \TestSub{-4}{1}{-5}%
  \TestSub{-1}{4}{-5}%
  \TestSub{4}{-1}{5}%
  \TestSub{1}{-4}{5}%
  \TestSub{-4}{-1}{-3}%
  \TestSub{-1}{-4}{3}%
  \TestSub{ -4 }{ -1 }{-3}%
  \TestSub{ -1 }{ -4 }{3}%
  \TestSub{ -4 }{ 1 }{-5}%
  \TestSub{ -1 }{ 4 }{-5}%
  \TestSub{ 4 }{ -1 }{5}%
  \TestSub{ 1 }{ -4 }{5}%
  \TestSub{ -4 }{ -1 }{-3}%
  \TestSub{ -1 }{ -4 }{3}%
  \TestSub{1000000000}{2}{999999998}%
  \TestSub{987654321}{111111111}{876543210}%
\end{qstest}

\begin{qstest}{shl}{shl}
  \TestShl{0}{0}%
  \TestShl{1}{2}%
  \TestShl{5621}{11242}%
  \TestShl{1073741823}{2147483646}%
  \TestShl{-1}{-2}%
  \TestShl{-5621}{-11242}%
\end{qstest}

\begin{qstest}{shr}{shr}
  \TestShr{0}{0}%
  \TestShr{1}{0}%
  \TestShr{2}{1}%
  \TestShr{3}{1}%
  \TestShr{4}{2}%
  \TestShr{5}{2}%
  \TestShr{6}{3}%
  \TestShr{7}{3}%
  \TestShr{8}{4}%
  \TestShr{9}{4}%
  \TestShr{10}{5}%
  \TestShr{11}{5}%
  \TestShr{12}{6}%
  \TestShr{13}{6}%
  \TestShr{14}{7}%
  \TestShr{15}{7}%
  \TestShr{16}{8}%
  \TestShr{17}{8}%
  \TestShr{18}{9}%
  \TestShr{19}{9}%
  \TestShr{20}{10}%
  \TestShr{21}{10}%
  \TestShr{22}{11}%
  \TestShr{11241}{5620}%
  \TestShr{73054202}{36527101}%
  \TestShr{2147483646}{1073741823}%
  \TestShr{-1}{0}%
  \TestShr{-2}{-1}%
  \TestShr{-3}{-1}%
  \TestShr{-11241}{-5620}%
\end{qstest}

\begin{qstest}{mul}{mul}
  \TestMul{0}{0}{0}%
  \TestMul{1}{0}{0}%
  \TestMul{0}{1}{0}%
  \TestMul{1}{1}{1}%
  \TestMul{3}{1}{3}%
  \TestMul{1}{-3}{-3}%
  \TestMul{-4}{-5}{20}%
  \TestMul{3}{7}{21}%
  \TestMul{7}{3}{21}%
  \TestMul{3}{-7}{-21}%
  \TestMul{7}{-3}{-21}%
  \TestMul{-3}{7}{-21}%
  \TestMul{-7}{3}{-21}%
  \TestMul{-3}{-7}{21}%
  \TestMul{-7}{-3}{21}%
  \TestMul{12}{11}{132}%
  \TestMul{999}{333}{332667}%
  \TestMul{1000}{4321}{4321000}%
  \TestMul{12345}{173955}{2147474475}%
  \TestMul{1073741823}{2}{2147483646}%
  \TestMul{2}{1073741823}{2147483646}%
  \TestMul{-1073741823}{2}{-2147483646}%
  \TestMul{2}{-1073741823}{-2147483646}%
\end{qstest}

\begin{qstest}{sqr}{sqr}
  \TestSqr{0}{0}%
  \TestSqr{1}{1}%
  \TestSqr{2}{4}%
  \TestSqr{3}{9}%
  \TestSqr{4}{16}%
  \TestSqr{9}{81}%
  \TestSqr{10}{100}%
  \TestSqr{46340}{2147395600}%
  \TestSqr{-1}{1}%
  \TestSqr{-2}{4}%
  \TestSqr{-46340}{2147395600}%
\end{qstest}

\begin{qstest}{pow}{pow}
  \TestPow{-2}{0}{1}%
  \TestPow{-1}{0}{1}%
  \TestPow{0}{0}{1}%
  \TestPow{1}{0}{1}%
  \TestPow{2}{0}{1}%
  \TestPow{3}{0}{1}%
  \TestPow{-2}{1}{-2}%
  \TestPow{-1}{1}{-1}%
  \TestPow{1}{1}{1}%
  \TestPow{2}{1}{2}%
  \TestPow{3}{1}{3}%
  \TestPow{-2}{2}{4}%
  \TestPow{-1}{2}{1}%
  \TestPow{0}{2}{0}%
  \TestPow{1}{2}{1}%
  \TestPow{2}{2}{4}%
  \TestPow{3}{2}{9}%
  \TestPow{0}{1}{0}%
  \TestPow{1}{-2}{1}%
  \TestPow{1}{-1}{1}%
  \TestPow{-1}{-2}{1}%
  \TestPow{-1}{-1}{-1}%
  \TestPow{-1}{3}{-1}%
  \TestPow{-1}{4}{1}%
  \TestPow{-2}{-1}{0}%
  \TestPow{-2}{-2}{0}%
  \TestPow{2}{3}{8}%
  \TestPow{2}{4}{16}%
  \TestPow{2}{5}{32}%
  \TestPow{2}{6}{64}%
  \TestPow{2}{7}{128}%
  \TestPow{2}{8}{256}%
  \TestPow{2}{9}{512}%
  \TestPow{2}{10}{1024}%
  \TestPow{-2}{3}{-8}%
  \TestPow{-2}{4}{16}%
  \TestPow{-2}{5}{-32}%
  \TestPow{-2}{6}{64}%
  \TestPow{-2}{7}{-128}%
  \TestPow{-2}{8}{256}%
  \TestPow{-2}{9}{-512}%
  \TestPow{-2}{10}{1024}%
  \TestPow{3}{3}{27}%
  \TestPow{3}{4}{81}%
  \TestPow{3}{5}{243}%
  \TestPow{-3}{3}{-27}%
  \TestPow{-3}{4}{81}%
  \TestPow{-3}{5}{-243}%
  \TestPow{2}{30}{1073741824}%
  \TestPow{-3}{19}{-1162261467}%
  \TestPow{5}{13}{1220703125}%
  \TestPow{-7}{11}{-1977326743}%
\end{qstest}

\begin{qstest}{div}{div}
  \TestDiv{1}{1}{1}%
  \TestDiv{2}{1}{2}%
  \TestDiv{-2}{1}{-2}%
  \TestDiv{2}{-1}{-2}%
  \TestDiv{-2}{-1}{2}%
  \TestDiv{15}{2}{7}%
  \TestDiv{-16}{2}{-8}%
  \TestDiv{1}{2}{0}%
  \TestDiv{1}{3}{0}%
  \TestDiv{2}{3}{0}%
  \TestDiv{-2}{3}{0}%
  \TestDiv{2}{-3}{0}%
  \TestDiv{-2}{-3}{0}%
  \TestDiv{13}{3}{4}%
  \TestDiv{-13}{-3}{4}%
  \TestDiv{-13}{3}{-4}%
  \TestDiv{-6}{5}{-1}%
  \TestDiv{-5}{5}{-1}%
  \TestDiv{-4}{5}{0}%
  \TestDiv{-3}{5}{0}%
  \TestDiv{-2}{5}{0}%
  \TestDiv{-1}{5}{0}%
  \TestDiv{0}{5}{0}%
  \TestDiv{1}{5}{0}%
  \TestDiv{2}{5}{0}%
  \TestDiv{3}{5}{0}%
  \TestDiv{4}{5}{0}%
  \TestDiv{5}{5}{1}%
  \TestDiv{6}{5}{1}%
  \TestDiv{-5}{4}{-1}%
  \TestDiv{-4}{4}{-1}%
  \TestDiv{-3}{4}{0}%
  \TestDiv{-2}{4}{0}%
  \TestDiv{-1}{4}{0}%
  \TestDiv{0}{4}{0}%
  \TestDiv{1}{4}{0}%
  \TestDiv{2}{4}{0}%
  \TestDiv{3}{4}{0}%
  \TestDiv{4}{4}{1}%
  \TestDiv{5}{4}{1}%
  \TestDiv{12345}{678}{18}%
  \TestDiv{32372}{5952}{5}%
  \TestDiv{284271294}{18162}{15651}%
  \TestDiv{217652429}{12561}{17327}%
  \TestDiv{462028434}{5439}{84947}%
  \TestDiv{2147483647}{1000}{2147483}%
  \TestDiv{2147483647}{-1000}{-2147483}%
  \TestDiv{-2147483647}{1000}{-2147483}%
  \TestDiv{-2147483647}{-1000}{2147483}%
\end{qstest}

\begin{qstest}{mod}{mod}
  \TestMod{-6}{5}{4}%
  \TestMod{-5}{5}{0}%
  \TestMod{-4}{5}{1}%
  \TestMod{-3}{5}{2}%
  \TestMod{-2}{5}{3}%
  \TestMod{-1}{5}{4}%
  \TestMod{0}{5}{0}%
  \TestMod{1}{5}{1}%
  \TestMod{2}{5}{2}%
  \TestMod{3}{5}{3}%
  \TestMod{4}{5}{4}%
  \TestMod{5}{5}{0}%
  \TestMod{6}{5}{1}%
  \TestMod{-5}{4}{3}%
  \TestMod{-4}{4}{0}%
  \TestMod{-3}{4}{1}%
  \TestMod{-2}{4}{2}%
  \TestMod{-1}{4}{3}%
  \TestMod{0}{4}{0}%
  \TestMod{1}{4}{1}%
  \TestMod{2}{4}{2}%
  \TestMod{3}{4}{3}%
  \TestMod{4}{4}{0}%
  \TestMod{5}{4}{1}%
  \TestMod{-6}{-5}{-1}%
  \TestMod{-5}{-5}{0}%
  \TestMod{-4}{-5}{-4}%
  \TestMod{-3}{-5}{-3}%
  \TestMod{-2}{-5}{-2}%
  \TestMod{-1}{-5}{-1}%
  \TestMod{0}{-5}{0}%
  \TestMod{1}{-5}{-4}%
  \TestMod{2}{-5}{-3}%
  \TestMod{3}{-5}{-2}%
  \TestMod{4}{-5}{-1}%
  \TestMod{5}{-5}{0}%
  \TestMod{6}{-5}{-4}%
  \TestMod{-5}{-4}{-1}%
  \TestMod{-4}{-4}{0}%
  \TestMod{-3}{-4}{-3}%
  \TestMod{-2}{-4}{-2}%
  \TestMod{-1}{-4}{-1}%
  \TestMod{0}{-4}{0}%
  \TestMod{1}{-4}{-3}%
  \TestMod{2}{-4}{-2}%
  \TestMod{3}{-4}{-1}%
  \TestMod{4}{-4}{0}%
  \TestMod{5}{-4}{-3}%
  \TestMod{2147483647}{1000}{647}%
  \TestMod{2147483647}{-1000}{-353}%
  \TestMod{-2147483647}{1000}{353}%
  \TestMod{-2147483647}{-1000}{-647}%
  \TestMod{ 0 }{ 4 }{0}%
  \TestMod{ 1 }{ 4 }{1}%
  \TestMod{ -1 }{ 4 }{3}%
  \TestMod{ 0 }{ -4 }{0}%
  \TestMod{ 1 }{ -4 }{-3}%
  \TestMod{ -1 }{ -4 }{-1}%
\end{qstest}
\newcommand*{\TestError}[2]{%
  \begingroup
    \expandafter\def\csname IntCalcError:#1\endcsname{}%
    \Expect*{#2}{0}%
    \expandafter\def\csname IntCalcError:#1\endcsname{ERROR}%
    \Expect*{#2}{0ERROR }%
  \endgroup
}
\begin{qstest}{error}{error}
  \TestError{FacNegative}{\intcalcFac{-1}}%
  \TestError{FacNegative}{\intcalcFac{-2147483647}}%
  \TestError{FacOverflow}{\intcalcFac{13}}%
  \TestError{FacOverflow}{\intcalcFac{2147483647}}%
  \TestError{DivisionByZero}{\intcalcPow{0}{-1}}%
  \TestError{DivisionByZero}{\intcalcDiv{1}{0}}%
  \TestError{DivisionByZero}{\intcalcMod{1}{0}}%
  \TestError{DivisionByZero}{\IntCalcDiv1!0!}%
  \TestError{DivisionByZero}{\IntCalcMod1!0!}%
\end{qstest}
\begin{document}
\end{document}
\endinput
%%
%% End of file `intcalc-test3.tex'.
