hnc-eduard/HNC/Excercises/задача на типы данных/main.py

45 lines
1.2 KiB
Python

def verify(actual, expected):
if type(actual) == str:
actual = actual.lower()
if type(expected) == str:
expected = expected.lower()
if type(actual) != type(expected):
return -1
elif type(actual) == type(expected) and actual == expected:
return 1
else:
return 0
#################################################
def verifier(test_data):
print(test_data[0])
result = verify(test_data[1], test_data[2])
if result != test_data[3]:
print("=======> FAILED! <====ф===")
print(f"Got result <{result}>")
print(f"Expected result is <{test_data[3]}>")
else:
print("PASSED")
print()
tests = [
("Integer test 1", 1, 2, 0),
("Integer test 2", 2, 2, 1),
("Integer test 3", 2, -2, 0),
("Integer test 4", True, 2, -1),
("String test 1", "ABC", "CBA", 0),
("String test 2", "ABC", "ABC", 1),
("String test 3", "ABC", "abc", 1),
("String test 4", True, "True", -1),
("Bool test 1", True, False, 0),
("Bool test 2", True, True, 1),
("Bool test 3", False, False, 1),
("Bool test 4", None, True, -1),
]
for test in tests:
verifier(test)