def test_build_from_cols(): passed = True failed_tests = [] options = [[[1, 2, 3], [1, 2, 3]], [[2, 3], [2, 3]]] for o_index, option in enumerate(options): test_matrix = Matrix.build_from_cols(option) for i in range(test_matrix.dimensions[0]): for j in range(test_matrix.dimensions[1]): if test_matrix.values[i][j] == option[j][i]: pass else: passed = False failed_tests.append(o_index) if not passed: print('TEST FAILED: Build from cols failed tests: {}.'.format( failed_tests)) else: print('TEST PASSED: Build from cols test passed.')
def test_build_from_arrays_initial(): passed = True failed_tests = [] options = [ 1, [1], [[], []], [[1], ['c']], [['a'], [1]], [[1, 2], [1]], [[1], [1, 2]], [[1, 2, 3], [1, 2, 3]] ] for o_index, option in enumerate(options): test_matrix = Matrix.build_from_rows(option) if o_index != len(options) - 1: if test_matrix.valid: passed = False failed_tests.append(o_index) else: if not test_matrix.valid: passed = False failed_tests.append(o_index) for o_index, option in enumerate(options): test_matrix = Matrix.build_from_cols(option) if o_index != len(options) - 1: if test_matrix.valid: passed = False failed_tests.append(o_index) else: if not test_matrix.valid: passed = False failed_tests.append(o_index) if not passed: print( 'TEST FAILED: Build from arrays initial failed tests: {}.'.format( failed_tests)) else: print('TEST PASSED: Build from arrays initial test passed.')