Skip to content

Commit 6aa8102

Browse files
authored
Merge pull request #7 from mohammadpagard/feature/add-tests
improve -Wrote the test for linear search algorithm.
2 parents f007c73 + e8bbce0 commit 6aa8102

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

search_algorithm/linear_search.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
def linear_search(array: list[int], target: int) -> str:
22
for i in range(len(array)):
33
if array[i] == target:
4-
return "The {} is in the {} index of the array".format(target, i)
5-
6-
return "Your target is not in the array..."
4+
return "The {} is in the {} index of the array.".format(target, i)
75

6+
return "Your target isn't in the array."

tests/search_algorithm/test_binary_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def timer(self):
1111
yield
1212
end_time = time.time()
1313
duration = end_time - start_time
14-
assert duration < 2, f"Test took too long: {duration:.4f} seconds"
14+
assert duration < 0.001, f"Test took too long: {duration:.4f} seconds"
1515

1616
def test_binary_search(self):
1717
nums = [

tests/search_algorithm/test_linear_search.py

Lines changed: 45 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)