Skip to content

Commit

Permalink
test: improve test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
luochen1990 committed Jul 21, 2024
1 parent 679a850 commit ff6e2ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions test/examples/binary_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

@ai_powered
def binary_search(arr: list[int], x: int) -> int:
''' Returns the index of x in arr if present, else -1 '''
''' Returns the index of x in arr if present, else -1, the index starts from 0
e.g.
binary_search([10, 101, 1002, 10003], 10) == 0
binary_search([10, 101, 1002, 10003], 10003) == 3
'''
...

def test_binary_search():

assert binary_search([1, 2, 100, 103, 104, 105], 103) == 3
assert binary_search([10, 20, 100, 103, 104, 105], 103) == 3
assert binary_search([1, 2, 100, 103, 104, 105], 2) == 1
2 changes: 1 addition & 1 deletion test/examples/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_calculator():
assert calculator("1+1") == 2
assert calculator("1+2*3") == 7
assert calculator("2^10+3*4") == 1036
assert calculator("2^10+sum(1,10)") == 1079
assert calculator("2^10+sum_from_to(1,10)") == 1079

0 comments on commit ff6e2ed

Please sign in to comment.