from cv06 import move_knight from time import sleep from typing import List, Tuple # run the script to test 'parameter_check()' function # DO NOT CHANGE THIS CODE! def test_knight(states: List[Tuple[Tuple[int, int], Tuple[int, int], Tuple[int, int], bool]]) -> None: print('TESTING STARTED:') result = True for i, state in enumerate(states): start, end, size, valid = state try: move_knight(start, end, size) if not valid: print('test {}: FAILED, the move is not valid'.format(i+1)) print('\t>> from {} to {} on a board size {}'. format(start, end, size)) result = False break except AssertionError: if valid: print('test {}: assertion error for a valid move!'.format(i)) print('\t>> from {} to {} on a board of size {}'.format(start, end, size)) result = False break except ValueError and TypeError as error: print('test {}: FAILED, the move is not valid'.format(i + 1)) print('\t>> from "{}" to "{}" on a desk size "{}"'.format(start, end, size)) print(error) result = False break sleep(0.001) print('test {}: OK'.format(i+1)) if result: print('\nYES! Your code passed all the tests!\nOne more task: please, check type control '// 'by "mypy"') else: print('TESTS FAILED!') inputs = [ ((0, 0), (1, 2), (8, 8), True), ((1, 2), (0, 0), (8, 8), True), ((3, 3), (1, 2), (8, 8), True), ((3, 3), (1, 4), (8, 8), True), ((3, 3), (5, 2), (8, 8), True), ((3, 3), (5, 4), (8, 8), True), ((3, 3), (2, 1), (8, 8), True), ((3, 3), (4, 1), (8, 8), True), ((-3, 3), (2, 5), (8, 8), False), ((3, -3), (4, 5), (8, 8), False), ((3, 3), (2, 5), (8, 8), True), ((3, 3), (4, 5), (8, 8), True), ((3, 3), (1, 2), (4, 4), True), ((3, 3), (1, 4), (4, 4), False), ((3, 3), (5, 2), (4, 4), False), ((3, 3), (5, 4), (4, 4), False), ((3, 3), (2, 1), (4, 4), True), ((3, 3), (4, 1), (4, 4), False), ((3, 3), (2, 5), (4, 4), False), ((3, 3), (4, 5), (4, 4), False), ((3, 3), (5, 4), (4, 4), False), ((3, 3), (4, 4), (5, 5), False), ((3, 3), (2, 2), (5, 5), False), ((3, 3), (2, 4), (5, 5), False), ((3, 3), (4, 2), (5, 5), False), ((3, 3), (3, 3), (5, 5), False), ((3, 3), (6, 3), (7, 9), False), ((3, 3), (3, 6), (10, 16), False), ((3, 3), (0, 3), (12, 11), False), ((3, 3), (3, 0), (9, 10), False), ((3, 3), (5, 4), (-8, 8), False), ((3, 3), (2, 1), (8, -8), False), ((1, 2), (3, 3), (8, 8), True), ((0, 0), (3, 4), (8, 8), False), ((1, 2), (1, 5), (8, 8), False), ((1, 2), (1, 5), (8, 8), False), ((0, 0), (-1, -2), (8, 8), False), ((0, 0), (1, 2), (0, 0), False), ((0, 0), (1, 2), (1, 1), False) ] test_knight(inputs)