A2osX/TESTS/IFSTRTEST.txt

215 lines
5.6 KiB
Plaintext
Raw Normal View History

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
2019-01-16 04:50:18 +00:00
IF [ "ABC" = "ABC" ]
Echo " Test 1 ABC = ABC : PASSED"
IF [ -N $Log ]
ECHO "Test 1 ABC = ABC : PASSED" >> ${Log}
SET P = $P + 1
FI
2019-01-16 04:50:18 +00:00
ELSE
Echo " Test 1 ABC = ABC : FAILED"
IF [ -N $Log ]
ECHO "Test 1 ABC = ABC : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Second Test that 2 unique constants are not equal.
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ "ABC" != "DEF" ]
Echo " Test 2 ABC != DEF : PASSED"
IF [ -N $Log ]
ECHO "Test 2 ABC != DEF : PASSED" >> ${Log}
SET P = $P + 1
FI
2019-01-16 04:50:18 +00:00
ELSE
Echo " Test 2 ABC != DEF : FAILED"
IF [ -N $Log ]
ECHO "Test 2 ABC != DEF : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Third test 2 similar but unequal constants are not equal.
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ "ABC" = "ABCD" ]
Echo " Test 3 ABC = ABCD : FAILED"
IF [ -N $Log ]
ECHO "Test 3 ABC = ABCD : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
ELSE
Echo " Test 3 ABC = ABCD : PASSED"
IF [ -N $Log ]
ECHO "Test 3 ABC = ABCD : PASSED" >> ${Log}
SET P = $P + 1
FI
2019-01-16 04:50:18 +00:00
FI
# Fourth test the same constants to be not equal to test for false.
SET T = $T + 1
2019-01-16 04:50:18 +00:00
IF [ "ABC" != "ABC" ]
Echo " Test 4 ABC != ABC : FAILED"
IF [ -N $Log ]
ECHO "Test 4 ABC != ABC : FAILED" >> ${Log}
SET F = $F + 1
FI
2019-01-16 04:50:18 +00:00
ELSE
Echo " Test 4 ABC != ABC : PASSED"
IF [ -N $Log ]
ECHO "Test 4 ABC != ABC : PASSED" >> ${Log}
SET P = $P + 1
FI
2019-01-16 04:50:18 +00:00
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
2019-03-01 18:19:14 +00:00
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
2019-03-12 04:05:03 +00:00
# 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}
2019-03-01 18:19:14 +00:00
FI
SET ABC =
SET DEF =
MAN
TEXT /MAKE/USR/SHARE/TESTS/IFSTRTEST