From ff6e2ed1ddc92314c53bd046c7a5b09bac60dd73 Mon Sep 17 00:00:00 2001 From: LuoChen Date: Sun, 21 Jul 2024 22:19:48 +0800 Subject: [PATCH] test: improve test cases --- test/examples/binary_search.py | 9 ++++++--- test/examples/calculator.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/test/examples/binary_search.py b/test/examples/binary_search.py index fd19177..40c38e4 100644 --- a/test/examples/binary_search.py +++ b/test/examples/binary_search.py @@ -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 diff --git a/test/examples/calculator.py b/test/examples/calculator.py index e3a6ec4..5d55524 100644 --- a/test/examples/calculator.py +++ b/test/examples/calculator.py @@ -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