Download backend/tests/reference/intervals_ref.py from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/backend/tests/reference/intervals_ref.py
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/backend/tests/reference/intervals_ref.py
-
curl -L -o intervals_ref.py https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/backend/tests/reference/intervals_ref.py
1.25 kB
| import pytest | |
| from solution import merge, total_length, contains, gaps, validate | |
| def test_merge_overlapping_and_adjacent(): | |
| assert merge([(5, 7), (1, 3), (2, 4), (8, 9)]) == [(1, 9)] | |
| def test_merge_disjoint_sorted(): | |
| assert merge([(10, 12), (1, 2)]) == [(1, 2), (10, 12)] | |
| def test_merge_empty(): | |
| assert merge([]) == [] | |
| def test_validate_rejects_reversed_and_wrong_size(): | |
| with pytest.raises(ValueError): | |
| validate((3, 1)) | |
| with pytest.raises(ValueError): | |
| validate((1, 2, 3)) | |
| def test_total_length_counts_integers(): | |
| assert total_length([(1, 3), (2, 5), (10, 10)]) == 6 | |
| def test_contains(x, expected): | |
| assert contains([(1, 4), (8, 12)], x) is expected | |
| def test_gaps_inside_bounds(): | |
| assert gaps([(3, 4), (7, 8)], 1, 10) == [(1, 2), (5, 6), (9, 10)] | |
| def test_gaps_ignores_outside_and_full_cover(): | |
| assert gaps([(-5, -1), (20, 30)], 0, 2) == [(0, 2)] | |
| assert gaps([(0, 10)], 0, 10) == [] | |
| def test_gaps_single_point_at_upper(): | |
| assert gaps([(0, 9)], 0, 10) == [(10, 10)] | |
| def test_gaps_invalid_bounds(): | |
| with pytest.raises(ValueError): | |
| gaps([], 5, 1) | |