def check_function_maximum(): """This function check the function maximum""" flag = [False, False, False, False, False] if not maximum([]): #empty list == False print("Test 1 succeed") flag[0] = True else: print("Test 1 failed") if maximum([0, 0, 0]) == 0: print("Test 2 succeed") flag[1] = True else: print("Test 2 failed") if maximum([1.5, 1.2, 1.49]) == 1.5: print("Test 3 succeed") flag[2] = True else: print("Test 3 failed") if maximum([5]) == 5: print("Test 4 succeed") flag[3] = True else: print("Test 4 failed") if maximum([1 / 2, 5 / 2, 5 / 3, 4 / 2]) == 5 / 2: print("Test 4 succeed") flag[4] = True else: print("Test 4 failed") if all(flag): return True return False
def check_max(): """ This function test if maximum function works well""" if maximum([1, 2, 3]) == 3: # check for first input subtest1 = True print("Congrats!, first subtest have succeed") else: subtest1 = False print('oops!, something went wrong with the first subtest') if maximum([0, 0, 0]) == 0: subtest2 = True print("Second subtest passed!") else: subtest2 = False print("second subtest faild!") if maximum([1, 2, 2]) == 2: subtest3 = True print("Third subtest succeed!") else: subtest3 = False print("There was a problem with 3rd subtest") if maximum([1]) == 1: subtest4 = True print("The last subtest is OK!") else: subtest4 = False print(" 4th subtest Faild!!") # check for forth input if subtest1 and subtest2 and subtest3 and subtest4: return True else: return False
def test(): """contains list of tests for maximum function. returns if the func past the test""" test_0 = maximum([]), None test_1 = maximum([2, 2, 2]), 2 test_2 = maximum([0, 3.0, 1]), 3.0 test_3 = maximum([3.5, 5, 5]), 5 tests = [test_0, test_1, test_2, test_3] return passed_test(tests)
def test(): if maximum([]) == None: print("Test 0 OK") else: print("Test 0 FAIL") if maximum([-1, -0.5, 0]) == 0: print("Test 1 OK") else: print("Test 1 FAIL") if maximum([100000, 1000000, 10000000]) == 10000000: print("Test 2 OK") else: print("Test 2 FAIL") if maximum([0.0001, 0.00001, 0.000001]) == 0.0001: print("Test 3 OK") else: print("Test 3 FAIL")
def test(): """ the function tests four different inputs to the maximum function. :return: 4 times 'test 1 is A-OK' prints """ if maximum([0]) == 0: print('Test 1 is A-OK') else: print('Test 1 Failed') if maximum([]) is None: print('Test 1 is A-OK') else: print('Test 1 Failed') if maximum([1, 1, 1]) == 1: print('Test 1 is A-OK') else: print('Test 1 Failed') if maximum([0, 0, 0]) == 0: print('Test 1 is A-OK') else: print('Test 1 Failed')
def test_maximum_case(num_test, array, expected): """ Checks if maximum(array) equals expected, and prints message accordingly. :param num_test: :param array: :param expected: :return: """ if maximum(array) == expected: print("Test", num_test, "OK") return print("Test", num_test, "FAIL")
def test(): ''' check the maximum function in ex3.py ''' tests = [[1, 2, 3], [3, 2, 1], [1, 3, 2], [1, 1, 1], [], [8, 8, 8, 9], [0], [0, 0, 0]] tests_res = [3, 3, 3, 1, None, 9, 0, 0] success = True for i in range(len(tests)): if maximum(tests[i]) == tests_res[i]: print("Test " + str(i + 1) + " OK") else: print("Test " + str(i + 1) + " FAIL") success = False return success
def test(): """ Test for the maximum function Prints a result for each test, and a general result - is everything okay :return: Boolean value, if the test succeeded """ flag = True if maximum([]) is not None: print("test 1 is fail") flag = False else: print("test 1 is OK") if maximum([2, 5]) != 5: print("test 2 is fail") flag = False else: print("test 2 is OK") if maximum([-65, -32, -73]) != -32: print("test 3 is fail") flag = False else: print("test 3 is OK") if maximum([1.00087, 1.001, 0.000015]) != 1.001: print("test 4 is fail") flag = False else: print("test 4 is OK") if maximum([-34, 0.1, 54, 99.9, -15.4]) != 99.9: print("test 5 is fail") flag = False else: print("test 5 is OK") if maximum([0, 0, 0]) != 0: print("test 6 is fail") flag = False else: print("test 6 is OK") if flag: # Check if everything is all right print("The test succeeded") else: print("The test fail") return flag
def test(): tests_lst = [ [], [4, 4, 4], [5, 2, 1], [0], [2, 10.9, 3.3], [0, 0, 3], ] correct_answers = [None, 4, 5, 0, 10.9, 3] passed = 0 for i in range(len(tests_lst)): if maximum(tests_lst[i]) == correct_answers[i]: print('test', i + 1, 'OK') passed += 1 else: print('test', i + 1, 'FAILED') if passed == 6: return True return False
def test_maximum(): assert maximum([1,2,3]) == 3 assert maximum([1.0,2.0,3.0]) == 3.0 assert maximum([0,0,0,0,0]) == 0 assert maximum([10, 10, 10.5]) == 10.5 assert maximum([1,1,1,10, 1,1,1,1, 11]) == 11