2018: day01: group up tests

This commit is contained in:
Antoine Martin 2019-12-05 00:03:26 +01:00
parent f0f872c199
commit 31d61e0e7e

View file

@ -38,45 +38,33 @@ fn part2(input: &str) -> Result<i32> {
mod tests { mod tests {
use super::*; use super::*;
#[test] const PROVIDED1: &str = "+1
fn part1_provided1() {
let input = "+1
-2 -2
+3 +3
+1 +1
"; ";
assert_eq!(part1(input).unwrap(), 3); const PROVIDED2: &str = "+1
}
#[test]
fn part1_provided2() {
let input = "+1
+1 +1
+1 +1
"; ";
assert_eq!(part1(input).unwrap(), 3); const PROVIDED3: &str = "+1
}
#[test]
fn part1_provided3() {
let input = "+1
+1 +1
-2 -2
"; ";
assert_eq!(part1(input).unwrap(), 0); const PROVIDED4: &str = "-1
}
#[test]
fn part1_provided4() {
let input = "-1
-2 -2
-3 -3
"; ";
assert_eq!(part1(input).unwrap(), -6); #[test]
fn part1_provided() {
assert_eq!(part1(PROVIDED1).unwrap(), 3);
assert_eq!(part1(PROVIDED2).unwrap(), 3);
assert_eq!(part1(PROVIDED3).unwrap(), 0);
assert_eq!(part1(PROVIDED4).unwrap(), -6);
} }
#[test] #[test]
@ -84,60 +72,38 @@ mod tests {
assert_eq!(part1(INPUT).unwrap(), 427); assert_eq!(part1(INPUT).unwrap(), 427);
} }
#[test] const PROVIDED5: &str = "+1
fn part2_provided1() {
let input = "+1
-2
+3
+1
";
assert_eq!(part2(input).unwrap(), 2);
}
#[test]
fn part2_provided2() {
let input = "+1
-1 -1
"; ";
assert_eq!(part2(input).unwrap(), 0); const PROVIDED6: &str = "+3
}
#[test]
fn part2_provided3() {
let input = "+3
+3 +3
+4 +4
-2 -2
-4 -4
"; ";
assert_eq!(part2(input).unwrap(), 10); const PROVIDED7: &str = "-6
}
#[test]
fn part2_provided4() {
let input = "-6
+3 +3
+8 +8
+5 +5
-6 -6
"; ";
assert_eq!(part2(input).unwrap(), 5); const PROVIDED8: &str = "+7
}
#[test]
fn part2_provided5() {
let input = "+7
+7 +7
-2 -2
-7 -7
-4 -4
"; ";
assert_eq!(part2(input).unwrap(), 14); #[test]
fn part2_provided() {
assert_eq!(part2(PROVIDED1).unwrap(), 2);
assert_eq!(part2(PROVIDED5).unwrap(), 0);
assert_eq!(part2(PROVIDED6).unwrap(), 10);
assert_eq!(part2(PROVIDED7).unwrap(), 5);
assert_eq!(part2(PROVIDED8).unwrap(), 14);
} }
#[test] #[test]