2019-02-22 03:47:12 +00:00
|
|
|
|
NEW
|
|
|
|
|
PREFIX
|
|
|
|
|
AUTO 4,1
|
|
|
|
|
#!/BIN/SH
|
|
|
|
|
#
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# This script tests the Numeric comparison options of the
|
|
|
|
|
# IF directive in shell.
|
2019-02-22 03:47:12 +00:00
|
|
|
|
#
|
|
|
|
|
#
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
SET T = 0
|
|
|
|
|
SET F = 0
|
|
|
|
|
SET P = 0
|
2019-01-16 04:50:18 +00:00
|
|
|
|
FI
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# 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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# 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 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Forth test different numbers -NE option
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ 99 -NE 79 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Fifth Test 99 < 79
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ 99 -LT 79 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Sixth Test 79 < 99
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ 79 -LT 99 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Seventh Test 99 <= 79
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ 99 -LE 79 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Eighth Test 79 <= 99
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ 79 -LE 99 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Nineth Test 99 <= 99
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ 99 -LE 99 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Tenth Test 99 > 79
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ 99 -GT 79 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Eleventh Test 79 > 99
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ 79 -GT 99 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Twelveth Test 99 => 79
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ 99 -GE 79 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Thirteenth Test 79 => 99
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ 79 -GE 99 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Fourteenth Test 99 => 99
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ 99 -GE 99 ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
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
|
|
|
|
|
# Fifteenth Test Dec Var to Constant Int
|
|
|
|
|
SET ABC = 1234.4321
|
|
|
|
|
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
|
|
|
|
|
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
|
2019-03-10 05:20:43 +00:00
|
|
|
|
SET ABC =
|
|
|
|
|
SET DEF =
|
|
|
|
|
SET GHI =
|
2019-02-22 03:47:12 +00:00
|
|
|
|
MAN
|
|
|
|
|
TEXT /MAKE/USR/SHARE/TESTS/IFNUMTEST
|