-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Expand file tree
/
Copy pathinterval.py
More file actions
22 lines (18 loc) · 791 Bytes
/
interval.py
File metadata and controls
22 lines (18 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pytest
def in_interval(number: int, start: int, end: int) -> bool:
return start <= number <= end
@pytest.mark.parametrize(
"number, start, end, expected",
[
(5, 1, 10, True), # Test case inside the interval
(1, 1, 10, True), # Edge case: number equals start
(10, 1, 10, True), # Edge case: number equals end
(0, 1, 10, False), # Number below the interval
(11, 1, 10, False), # Number above the interval
(5, 5, 5, True), # Edge case: start equals end equals number
(-1, -5, 5, True), # Test case with negative numbers
(-6, -5, 5, False), # Number below the interval with negatives
],
)
def test_in_interval(number, start, end, expected):
assert in_interval(number, start, end) == expected