day 2 - part 2 - refactoring
This commit is contained in:
parent
6e40648ec6
commit
9d8f70f0a8
7 changed files with 0 additions and 0 deletions
68
tests/aoc_2024/day2/test_part2.py
Normal file
68
tests/aoc_2024/day2/test_part2.py
Normal file
|
@ -0,0 +1,68 @@
|
|||
from pathlib import Path
|
||||
|
||||
from aoc_2024.day2 import part2
|
||||
|
||||
|
||||
def test_report_with_tolerance_with_decreasing_levels_less_than_3_is_safe():
|
||||
report = [7, 6, 4, 2, 1]
|
||||
assert part2.is_report_safe_with_tolerance(report)
|
||||
|
||||
|
||||
def test_report_with_tolerance_with_decreasing_levels_more_than_3_is_not_safe():
|
||||
report = [9, 7, 6, 2, 1]
|
||||
assert not part2.is_report_safe_with_tolerance(report)
|
||||
|
||||
|
||||
def test_report_with_tolerance_without_increasing_or_decreasing_levels_is_not_safe():
|
||||
report = [8, 6, 4, 4, 1]
|
||||
assert part2.is_report_safe_with_tolerance(report)
|
||||
|
||||
|
||||
def test_report_with_tolerance_with_increasing_and_decreasing_levels_is_not_safe():
|
||||
report = [1, 3, 2, 4, 5]
|
||||
assert part2.is_report_safe_with_tolerance(report)
|
||||
|
||||
|
||||
def test_report_with_tolerance_with_increasing_levels_less_than_3_is_safe():
|
||||
report = [1, 3, 6, 7, 9]
|
||||
assert part2.is_report_safe_with_tolerance(report)
|
||||
|
||||
|
||||
def test_report_with_tolerance_with_increasing_levels_more_than_3_is_not_safe():
|
||||
report = [1, 2, 7, 8, 9]
|
||||
assert not part2.is_report_safe_with_tolerance(report)
|
||||
|
||||
|
||||
def test_report_with_decreasing_levels_less_than_3_is_safe():
|
||||
report = [7, 6, 4, 2, 1]
|
||||
assert part2.is_report_safe(report)
|
||||
|
||||
|
||||
def test_report_with_decreasing_levels_more_than_3_is_not_safe():
|
||||
report = [9, 7, 6, 2, 1]
|
||||
assert not part2.is_report_safe(report)
|
||||
|
||||
|
||||
def test_report_without_increasing_or_decreasing_levels_is_not_safe():
|
||||
report = [8, 6, 4, 4, 1]
|
||||
assert not part2.is_report_safe(report)
|
||||
|
||||
|
||||
def test_report_with_increasing_and_decreasing_levels_is_not_safe():
|
||||
report = [1, 3, 2, 4, 5]
|
||||
assert not part2.is_report_safe(report)
|
||||
|
||||
|
||||
def test_report_with_increasing_levels_less_than_3_is_safe():
|
||||
report = [1, 3, 6, 7, 9]
|
||||
assert part2.is_report_safe(report)
|
||||
|
||||
|
||||
def test_report_with_increasing_levels_more_than_3_is_not_safe():
|
||||
report = [1, 2, 7, 8, 9]
|
||||
assert not part2.is_report_safe(report)
|
||||
|
||||
|
||||
def test_read_records_file():
|
||||
test_file = Path(__file__).parent / "test-data"
|
||||
assert part2.main(test_file) == 4
|
Loading…
Add table
Add a link
Reference in a new issue