[CMD_ROSTEST] Add tests for SET /A errorlevels.

This commit is contained in:
Hermès Bélusca-Maïto 2020-07-27 16:46:49 +02:00
parent 87a5403318
commit f5cf67f455
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 85 additions and 0 deletions

View file

@ -498,6 +498,62 @@ goto :eof
:continue
:: Testing different ERRORLEVELs from the SET command.
:: See https://ss64.com/nt/set.html for more details.
echo ---------- Testing SET /A ERRORLEVELs ----------
echo --- Success
call :setError 0
set /a "total=1+1"
call :checkErrorLevel 0
echo %errorlevel%
echo %total%
echo --- Unbalanced parentheses
call :setError 0
set /a "total=(2+1"
call :checkErrorLevel 1073750988
echo %errorlevel%
echo %total%
echo --- Missing operand
call :setError 0
set /a "total=5*"
call :checkErrorLevel 1073750989
echo %errorlevel%
echo %total%
echo --- Syntax error
call :setError 0
set /a "total=7$3"
call :checkErrorLevel 1073750990
echo %errorlevel%
echo %total%
echo --- Invalid number
call :setError 0
set /a "total=0xdeadbeeg"
call :checkErrorLevel 1073750991
echo %errorlevel%
echo %total%
echo --- Number larger than 32-bits
call :setError 0
set /a "total=999999999999999999999999"
call :checkErrorLevel 1073750992
echo %errorlevel%
echo %total%
echo --- Division by zero
call :setError 0
set /a "total=1/0"
call :checkErrorLevel 1073750993
echo %errorlevel%
echo %total%
::
:: Finished!
::

View file

@ -130,4 +130,33 @@ OK
0
0
0
---------- Testing SET /A ERRORLEVELs ----------
--- Success
OK
0
2
--- Unbalanced parentheses
OK
1073750988
2
--- Missing operand
OK
1073750989
2
--- Syntax error
OK
1073750990
7
--- Invalid number
OK
1073750991
7
--- Number larger than 32-bits
OK
1073750992
7
--- Division by zero
OK
1073750993
7
--------- Finished --------------