Ejemplo n.º 1
0
def test_integerbinarysearch():
    input1 = 5
    input2 = [23, 67, 12, 90, 54]
    input3 = 67
    result = binarysearch(input1, input2, input3)
    expected = 3
    assert result == expected
Ejemplo n.º 2
0
def test_integerbinaryseachcorrectinput():
    result = binarysearch(json_string['integerbinarysearch'][4]['input1'],
                          json_string['integerbinarysearch'][4]['input2'],
                          json_string['integerbinarysearch'][4]['input3'])
    expected = json_string['integerbinarysearch'][4]['output']
    assert result == expected
Ejemplo n.º 3
0
            break
        else:
            print("Enter Positive integers only")
            continue
    except ValueError:
        print("Please enter number only")
        continue

#writing those elements into a list
print("Enter the elements : ")
list1 = []
for i in range(0, n):
    try:
        d = int(input())
    except ValueError:
        print("Please enter integers only")
        sys.exit()
    list1.append(int(d))

while True:
    try:
        # Getting the element which the user wants to search
        print("Enter the element which you want to search : ")
        elem = int(input())
        break
    except ValueError:
        print("Please enter numbers only")

#calling the function in the BL file
item = utility.binarysearch(n, list1, elem)