mirror of
https://github.com/A2osX/A2osX.git
synced 2024-10-30 01:26:10 +00:00
215 lines
5.6 KiB
Plaintext
215 lines
5.6 KiB
Plaintext
NEW
|
||
PREFIX
|
||
AUTO 4,1
|
||
#!/BIN/SH
|
||
#
|
||
# This script tests the String comparison options of the
|
||
# IF directive in shell.
|
||
#
|
||
#!/BIN/SH
|
||
ECHO "\f\n\n IF String Tests"
|
||
ECHO "\n\nThis Performs Several String Comparison Tests"
|
||
ECHO
|
||
ECHO "Begin IF String Tests"
|
||
ECHO
|
||
IF [ -N $Log ]
|
||
ECHO "Begin IF String Tests" >> ${Log}
|
||
ELSE
|
||
SET T = 0
|
||
SET F = 0
|
||
SET P = 0
|
||
FI
|
||
# First test that 2 of the same constants equal each other.
|
||
SET T = $T + 1
|
||
IF [ "ABC" = "ABC" ]
|
||
Echo " Test 1 ABC = ABC : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 1 ABC = ABC : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 1 ABC = ABC : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 1 ABC = ABC : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# Second Test that 2 unique constants are not equal.
|
||
SET T = $T + 1
|
||
IF [ "ABC" != "DEF" ]
|
||
Echo " Test 2 ABC != DEF : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 2 ABC != DEF : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 2 ABC != DEF : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 2 ABC != DEF : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# Third test 2 similar but unequal constants are not equal.
|
||
SET T = $T + 1
|
||
IF [ "ABC" = "ABCD" ]
|
||
Echo " Test 3 ABC = ABCD : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 3 ABC = ABCD : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 3 ABC = ABCD : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 3 ABC = ABCD : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# Fourth test the same constants to be not equal to test for false.
|
||
SET T = $T + 1
|
||
IF [ "ABC" != "ABC" ]
|
||
Echo " Test 4 ABC != ABC : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 4 ABC != ABC : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 4 ABC != ABC : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 4 ABC != ABC : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# Fifth test compare VAR to constant to be equal.
|
||
SET ABC = "ABC"
|
||
SET T = $T + 1
|
||
IF [ $ABC = "ABC" ]
|
||
Echo " Test 5 VAR = ABC : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 5 VAR = ABC : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 5 VAR = ABC : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 5 VAR = ABC : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# Sixth test compare complex VAR to constant to be equal.
|
||
SET ABC = "ABC"
|
||
SET DEF = "${ABC}123${ABC}456${ABC}"
|
||
SET T = $T + 1
|
||
IF [ $DEF = "ABC123ABC456ABC" ]
|
||
Echo " Test 6 Complex VAR = ABC123ABC456ABC : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 6 Complex VAR = ABC123ABC456ABC : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 6 Complex VAR = ABC123ABC456ABC : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 6 Complex VAR = ABC123ABC456ABC : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
|
||
# Seventh test new .> comparison option ABC and DEF
|
||
SET T = $T + 1
|
||
IF [ "ABC" .> "DEF" ]
|
||
Echo " Test 7 ABC .> DEF : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 7 ABC .> DEF : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 7 ABC .> DEF : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 7 ABC .> DEF : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# Eighth test new .< comparison option ABC and DEF
|
||
SET T = $T + 1
|
||
IF [ "ABC" .< "DEF" ]
|
||
Echo " Test 8 ABC .< DEF : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 8 ABC .< DEF : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 8 ABC .< DEF : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 8 ABC .< DEF : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# Nineth test new >= comparison option ABC and DEF
|
||
SET T = $T + 1
|
||
IF [ "ABC" >= "DEF" ]
|
||
Echo " Test 9 ABC >= DEF : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 9 ABC >= DEF : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 9 ABC >= DEF : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 9 ABC >= DEF : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# Tenth test new <= comparison option ABC and DEF
|
||
SET T = $T + 1
|
||
IF [ "ABC" <= "DEF" ]
|
||
Echo " Test 10 ABC <= DEF : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 10 ABC <= DEF : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 10 ABC <= DEF : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 10 ABC <= DEF : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# Eleventh test new >= comparison option ABC and ABC
|
||
SET T = $T + 1
|
||
IF [ "ABC" >= "ABC" ]
|
||
Echo " Test 10 ABC >= ABC : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 10 ABC >= ABC : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 10 ABC >= ABC : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 10 ABC >= ABC : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# Twelveth test new <= comparison option ABC and ABC
|
||
SET T = $T + 1
|
||
IF [ "ABC" <= "ABC" ]
|
||
Echo " Test 10 ABC <= ABC : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 10 ABC <= ABC : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 10 ABC <= ABC : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 10 ABC <= ABC : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
ECHO "\nEnd IF String Tests"
|
||
ECHO
|
||
IF [ -N $Log ]
|
||
ECHO "End IF String Tests" >> ${Log}
|
||
FI
|
||
SET ABC =
|
||
SET DEF =
|
||
MAN
|
||
TEXT /MAKE/USR/SHARE/TESTS/IFSTRTEST
|