Skip to content

Commit 533c79c

Browse files
committed
refactor tests
1 parent af7792e commit 533c79c

File tree

1 file changed

+45
-32
lines changed

1 file changed

+45
-32
lines changed

tests/year_2025/test_day_01.py

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from advent_of_code.year_2025.day_01 import (
33
solve,
44
turn_dial,
5-
passing_zero_counter,
5+
position_counter,
66
)
77

88

@@ -24,45 +24,58 @@ def day_01_test_input():
2424

2525
@pytest.fixture
2626
def day_01_expected_output():
27-
return (3, None)
27+
return (3, 6)
2828

2929

3030
def test_solver(day_01_test_input, day_01_expected_output):
3131
result = solve(day_01_test_input)
3232
assert result == day_01_expected_output
3333

34-
@pytest.mark.parametrize(
35-
"current_position, turn_direction, distance, expected_new_position",
36-
[
37-
(50, -1, 68, 82),
38-
(82, -1, 30, 52),
39-
(52, 1, 48, 0),
40-
(0, -1, 5, 95),
41-
(95, 1, 60, 55),
42-
(55, -1, 55, 0),
43-
(0, -1, 1, 99),
44-
(99, -1, 99, 0),
45-
(0, 1, 14, 14),
46-
(14, -1, 82, 32),
34+
@pytest.fixture(params=[
35+
(50 , -1 , 68 , 82 , 0 , 1 ),
36+
(82 , -1 , 30 , 52 , 0 , 0 ),
37+
(52 , 1 , 48 , 0 , 1 , 1 ),
38+
(0 , -1 , 5 , 95 , 0 , 0 ),
39+
(95 , 1 , 60 , 55 , 0 , 1 ),
40+
(55 , -1 , 55 , 0 , 1 , 1 ),
41+
(0 , -1 , 1 , 99 , 0 , 0 ),
42+
(99 , -1 , 99 , 0 , 1 , 1 ),
43+
(0 , 1 , 14 , 14 , 0 , 0 ),
44+
(14 , -1 , 82 , 32 , 0 , 1 ),
4745
],
4846
)
49-
def test_turn_dial(current_position, turn_direction, distance, expected_new_position):
47+
def turn_case(request):
48+
"""
49+
(current_position, turn_direction, distance, expected_new_position, part_1_count, part_2_count)
50+
51+
"""
52+
return request.param
53+
54+
def test_turn_dial(turn_case):
55+
current_position, turn_direction, distance, expected_new_position, _, _ = turn_case
5056
new_position = turn_dial(current_position, turn_direction, distance)
5157
assert new_position == expected_new_position
5258

53-
@pytest.mark.parametrize(
54-
"start_position, turn_direction, distance, expected_count",
55-
[
56-
(50, 1, 1000, 10),
57-
# (50, 1, 49, 0),
58-
# (50, -1, 49, 0),
59-
# (50, -1, 50, 1),
60-
# (50, -1, 51, 1),
61-
# (99, 1, 1, 1),
62-
# (99, -1, 1, 0),
63-
# (0, 1, 100, 1),
64-
]
65-
)
66-
def test_passing_zero_counter(start_position, turn_direction, distance, expected_count):
67-
count = passing_zero_counter(start_position, turn_direction, distance)
68-
assert count == expected_count
59+
60+
def test_position_counter(turn_case):
61+
_, _, _, expected_new_position, expected_count, _ = turn_case
62+
actual_count = position_counter(expected_new_position)
63+
assert actual_count == expected_count
64+
65+
66+
# @pytest.mark.parametrize(
67+
# "start_position, turn_direction, distance, expected_count",
68+
# [
69+
# (50, 1, 1000, 10),
70+
# # (50, 1, 49, 0),
71+
# # (50, -1, 49, 0),
72+
# # (50, -1, 50, 1),
73+
# # (50, -1, 51, 1),
74+
# # (99, 1, 1, 1),
75+
# # (99, -1, 1, 0),
76+
# # (0, 1, 100, 1),
77+
# ]
78+
# )
79+
# def test_passing_zero_counter(start_position, turn_direction, distance, expected_count):
80+
# count = passing_zero_counter(start_position, turn_direction, distance)
81+
# assert count == expected_count

0 commit comments

Comments
 (0)