A2osX/TESTS/IFNUMTEST.txt

420 lines
11 KiB
Plaintext
Raw Normal View History

NEW
PREFIX
AUTO 4,1
#!/BIN/SH
#
# This script tests the Numeric comparison options of the
# IF directive in shell.
#
#
ECHO "\f\n\n If Numeric Tests"
ECHO "\n\nThis Performs Several Numeric Comparison Tests"
ECHO
ECHO "Begin IF Numeric Tests"
ECHO
IF [ -N $Log ]
ECHO "Begin IF Numeric Tests" >> ${Log}
2019-01-16 04:50:18 +00:00
ELSE
SET T = 0
SET F = 0
SET P = 0
2019-01-16 04:50:18 +00:00
FI
# First test that 2 of the same constants numbers are equal each other.
SET T = $T + 1
IF [ 99 -EQ 99 ]
Echo " Test 1 99 -EQ 99 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 1 99 -EQ 99 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
2019-01-16 04:50:18 +00:00
ELSE
Echo " Test 1 99 -EQ 99 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 1 99 -EQ 99 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Second Test that 2 unique numbers fail -EQ test.
SET T = $T + 1
IF [ 99 -EQ 79 ]
Echo " Test 2 99 -EQ 79 : True : FAILED"
IF [ -N $Log ]
ECHO "Test 2 99 -EQ 79 : True : FAILED" >> ${Log}
SET F = $F + 1
FI
ELSE
Echo " Test 2 99 -EQ 79 : False : PASSED"
IF [ -N $Log ]
ECHO "Test 2 99 -EQ 79 : False : PASSED" >> ${Log}
SET P = $P + 1
FI
FI
# Third Test Same Number -NE option
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 99 -NE 99 ]
Echo " Test 3 99 -NE 99 : True : FAILED"
IF [ -N $Log ]
ECHO "Test 3 99 -NE 99 : True : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
ELSE
Echo " Test 3 99 -NE 99 : False : PASSED"
IF [ -N $Log ]
ECHO "Test 3 99 -NE 99 : False : PASSED" >> ${Log}
SET P = $P + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Forth test different numbers -NE option
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 99 -NE 79 ]
Echo " Test 4 99 -NE 79 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 4 99 -NE 79 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
2019-01-16 04:50:18 +00:00
ELSE
Echo " Test 4 99 -NE 79 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 4 99 -NE 79 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Fifth Test 99 < 79
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 99 -LT 79 ]
Echo " Test 5 99 -LT 79 : True : FAILED"
IF [ -N $Log ]
ECHO "Test 5 99 -LT 79 : True : FAILED" >> ${Log}
SET F = $F + 1
FI
ELSE
Echo " Test 5 99 -LT 79 : False : PASSED"
IF [ -N $Log ]
ECHO "Test 5 99 -LT 79 : False : PASSED" >> ${Log}
SET P = $P + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Sixth Test 79 < 99
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 79 -LT 99 ]
Echo " Test 6 79 -LT 99 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 6 79 -LT 99 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 6 79 -LT 99 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 6 79 -LT 99 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Seventh Test 99 <= 79
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 99 -LE 79 ]
Echo " Test 7 99 -LE 79 : True : FAILED"
IF [ -N $Log ]
ECHO "Test 7 99 -LE 79 : True : FAILED" >> ${Log}
SET F = $F + 1
FI
ELSE
Echo " Test 7 99 -LE 79 : False : PASSED"
IF [ -N $Log ]
ECHO "Test 7 99 -LE 79 : False : PASSED" >> ${Log}
SET P = $P + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Eighth Test 79 <= 99
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 79 -LE 99 ]
Echo " Test 8 79 -LE 99 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 8 79 -LE 99 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 8 79 -LE 99 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 8 79 -LE 99 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Nineth Test 99 <= 99
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 99 -LE 99 ]
Echo " Test 9 99 -LE 99 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 9 99 -LE 99 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 9 99 -LE 99 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 9 99 -LE 99 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Tenth Test 99 > 79
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 99 -GT 79 ]
Echo " Test 10 99 -GT 79 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 10 99 -GT 79 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 10 99 -GT 79 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 10 99 -GT 79 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Eleventh Test 79 > 99
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 79 -GT 99 ]
Echo " Test 11 79 -GT 99 : True : FAILED"
IF [ -N $Log ]
ECHO "Test 11 79 -GT 99 : True : FAILED" >> ${Log}
SET F = $F + 1
FI
ELSE
Echo " Test 11 79 -GT 99 : False : PASSED"
IF [ -N $Log ]
ECHO "Test 11 79 -GT 99 : False : PASSED" >> ${Log}
SET P = $P + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Twelveth Test 99 => 79
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 99 -GE 79 ]
Echo " Test 12 99 -GE 79 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 12 99 -GE 79 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 12 99 -GE 79 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 12 99 -GE 79 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Thirteenth Test 79 => 99
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 79 -GE 99 ]
Echo " Test 13 79 -GE 99 : True : FAILED"
IF [ -N $Log ]
ECHO "Test 13 79 -GE 99 : True : FAILED" >> ${Log}
SET F = $F + 1
FI
ELSE
Echo " Test 13 79 -GE 99 : False : PASSED"
IF [ -N $Log ]
ECHO "Test 13 79 -GE 99 : False : PASSED" >> ${Log}
SET P = $P + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Fourteenth Test 99 => 99
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ 99 -GE 99 ]
Echo " Test 14 99 -GE 99 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 14 99 -GE 99 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 14 99 -GE 99 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 14 99 -GE 99 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
FI
2019-11-29 20:29:25 +00:00
# Fifteenth Test Int Var to Constant Int
SET ABC = 1234
SET T = $T + 1
IF [ $ABC -EQ 1234 ]
Echo " Test 15 Dec Var to Int : True : PASSED"
IF [ -N $Log ]
ECHO "Test 15 Dec Var to Int : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 15 Dec Var to Int : False : FAILED"
IF [ -N $Log ]
ECHO "Test 15 Dec Var to Int : False : FAILED" >> ${Log}
SET F = $F + 1
FI
FI
# Sixteenth Test Upper Limit Rollover
SET ABC = 2147483645
SET DEF = $ABC + 3
SET T = $T + 1
IF [ $DEF -EQ -2147483648 ]
Echo " Test 16 Upper Rollover : True : PASSED"
IF [ -N $Log ]
ECHO "Test 16 Upper Rollover : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 16 Upper Rollover : False : FAILED"
IF [ -N $Log ]
ECHO "Test 16 Upper Rollover : False : FAILED" >> ${Log}
SET F = $F + 1
FI
FI
# Seventeenth Test Lower Limit Rollover
SET GHI = $DEF - 5
SET T = $T + 1
IF [ $GHI -EQ 2147483643 ]
Echo " Test 17 Lower Rollover : True : PASSED"
IF [ -N $Log ]
ECHO "Test 17 Lower Rollover : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 17 Lower Rollover : False : FAILED"
IF [ -N $Log ]
ECHO "Test 17 Lower Rollover : False : FAILED" >> ${Log}
SET F = $F + 1
FI
FI
# 18th Test * or Multiplication Test 1
SET T = $T + 1
SET GHI = 10 * 7 * 3 * 5
IF [ $GHI -EQ 1050 ]
Echo " Test 18 Multiplication 1 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 18 Multiplication 1 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 18 Multiplication 1 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 18 Multiplication 1 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
FI
# 19th Test * or Multiplication Test 2
SET T = $T + 1
SET GHI = 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9
IF [ $GHI -EQ 362880 ]
Echo " Test 19 Multiplication 2 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 19 Multiplication 2 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 19 Multiplication 2 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 19 Multiplication 2 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
FI
# 20th Test / or Division Test 1
SET T = $T + 1
SET GHI = 362880 / 9 / 8 / 7 / 6 / 5
IF [ $GHI -EQ 24 ]
Echo " Test 20 Division 1 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 20 Division 1 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 20 Division 1 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 20 Division 1 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
FI
# 21th Test / or Division Test 2
SET T = $T + 1
SET GHI = 100000 / 100 / 20 / 5
IF [ $GHI -EQ 10 ]
Echo " Test 21 Division 2 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 21 Division 2 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 21 Division 2 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 21 Division 2 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
FI
# 22th Test MOD 1
SET T = $T + 1
SET GHI = 27 MOD 7
IF [ $GHI -EQ 6 ]
Echo " Test 22 MOD 1 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 22 MOD 1 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 22 MOD 1 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 22 MOD 1 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
FI
# 23th Test MOD 2
SET T = $T + 1
SET GHI = 198 MOD 30
IF [ $GHI -EQ 18 ]
Echo " Test 23 MOD 2 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 23 MOD 2 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 23 MOD 2 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 23 MOD 2 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
FI
# 24th Test Complex Math 1
SET T = $T + 1
SET GHI = 2 * 3 + 8 * 14 / 4 - 4 / 9 * 5
IF [ $GHI -EQ 25 ]
Echo " Test 24 Complex 1 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 24 Complex 1 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 24 Complex 1 : False : FAILED"
IF [ -N $Log ]
ECHO "Test 24 Complex 1 : False : FAILED" >> ${Log}
SET F = $F + 1
FI
FI
# 25th Test Complex Math 2
SET T = $T + 1
SET GHI = 22 - 50 / 14 + 4 * 28 - 64
IF [ $GHI -EQ -8 ]
Echo " Test 25 Complex 2 : True : PASSED"
IF [ -N $Log ]
ECHO "Test 25 Complex 2 : True : PASSED" >> ${Log}
SET P = $P + 1
FI
ELSE
Echo " Test 25 Complex 2 : False : FAILED - $GHI"
IF [ -N $Log ]
ECHO "Test 25 Complex 2 : False : FAILED - $GHI" >> ${Log}
SET F = $F + 1
FI
FI
ECHO
ECHO "End IF Numeric Tests"
ECHO
IF [ -N $Log ]
ECHO "End IF Numeric Tests" >> ${Log}
2019-01-16 04:50:18 +00:00
FI
SET ABC =
SET DEF =
SET GHI =
MAN
TEXT /MAKE/USR/SHARE/TESTS/IFNUMTEST