Skip to content

Commit d3d0049

Browse files
committed
refactor(08/2025): simplify day creation
1 parent 131c601 commit d3d0049

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/solutions/year2025/day08.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use crate::solutions::Solution;
22
use crate::utils::point3d::Point3D;
33
use itertools::Itertools;
44

5+
#[cfg(not(test))]
56
const INPUT_CONNECTIONS: usize = 1_000;
7+
#[cfg(test)]
8+
const TEST_CONNECTIONS: usize = 10;
69

710
type Pair = (Point3D, Point3D);
811

@@ -104,6 +107,7 @@ impl Day08 {
104107
}
105108
}
106109

110+
#[cfg(not(test))]
107111
impl Default for Day08 {
108112
fn default() -> Self {
109113
Self {
@@ -112,21 +116,20 @@ impl Default for Day08 {
112116
}
113117
}
114118

119+
#[cfg(test)]
120+
impl Default for Day08 {
121+
fn default() -> Self {
122+
Self {
123+
connections: TEST_CONNECTIONS,
124+
}
125+
}
126+
}
127+
115128
#[cfg(test)]
116129
mod tests {
117130
use crate::solutions::year2025::day08::Day08;
118131
use crate::solutions::Solution;
119132

120-
const TEST_CONNECTIONS: usize = 10;
121-
122-
impl Day08 {
123-
fn new_for_tests() -> Self {
124-
Self {
125-
connections: TEST_CONNECTIONS,
126-
}
127-
}
128-
}
129-
130133
const EXAMPLE: &str = r#"162,817,812
131134
57,618,57
132135
906,360,560
@@ -150,11 +153,11 @@ mod tests {
150153

151154
#[test]
152155
fn part_one_example_test() {
153-
assert_eq!("40", Day08::new_for_tests().part_one(EXAMPLE));
156+
assert_eq!("40", Day08::default().part_one(EXAMPLE));
154157
}
155158

156159
#[test]
157160
fn part_two_example_test() {
158-
assert_eq!("25272", Day08::new_for_tests().part_two(EXAMPLE));
161+
assert_eq!("25272", Day08::default().part_two(EXAMPLE));
159162
}
160163
}

0 commit comments

Comments
 (0)