forked from TheAlgorithms/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.patch
More file actions
40 lines (40 loc) · 1.98 KB
/
Copy pathtest.patch
File metadata and controls
40 lines (40 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
diff --git a/test.sh b/test.sh
new file mode 100644
index 00000000..23bcf547
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+set -uo pipefail
+cd /app
+
+MODE="${1:-new}"
+
+case "$MODE" in
+ base)
+ pytest tests # run existing repo tests
+ ;;
+ new)
+ pytest tests/test_binary_search_duplicates.py
+ ;;
+ *)
+ echo "unknown mode: $MODE (expected base or new)" >&2
+ exit 2
+ ;;
+esac
\ No newline at end of file
diff --git a/tests/test_binary_search_duplicates.py b/tests/test_binary_search_duplicates.py
new file mode 100644
index 00000000..1030c868
--- /dev/null
+++ b/tests/test_binary_search_duplicates.py
@@ -0,0 +1,8 @@
+def test_binary_search_leftmost_duplicate():
+ assert binary_search([1, 2, 2, 2, 3], 2) == 1
+
+def test_binary_search_all_duplicates():
+ assert binary_search([1, 1, 1, 1], 1) == 0
+
+def test_binary_search_not_found():
+ assert binary_search([1, 2, 3], 4) == -1
\ No newline at end of file