mirror of
https://github.com/rjNemo/ai_advent_code_2024
synced 2026-06-06 02:26:44 +00:00
test: Add comprehensive tests for Day 2 Part 2 Problem Dampener functionality
This commit is contained in:
parent
bc2091cb79
commit
d74989b5c4
1 changed files with 43 additions and 0 deletions
|
|
@ -54,4 +54,47 @@ defmodule AdventCode2024.Solutions.Day2Test do
|
|||
assert Day2.solve("not numbers") == {:error, :invalid_format}
|
||||
end
|
||||
end
|
||||
|
||||
describe "solve_part2/1" do
|
||||
test "correctly identifies safe reports with Problem Dampener from example data" do
|
||||
input = """
|
||||
7 6 4 2 1
|
||||
1 2 7 8 9
|
||||
9 7 6 2 1
|
||||
1 3 2 4 5
|
||||
8 6 4 4 1
|
||||
1 3 6 7 9
|
||||
"""
|
||||
|
||||
assert Day2.solve_part2(input) == {:ok, 4}
|
||||
end
|
||||
|
||||
test "identifies a report made safe by removing middle number" do
|
||||
input = "1 3 2 4 5\n"
|
||||
assert Day2.solve_part2(input) == {:ok, 1}
|
||||
end
|
||||
|
||||
test "identifies a report made safe by removing duplicate number" do
|
||||
input = "8 6 4 4 1\n"
|
||||
assert Day2.solve_part2(input) == {:ok, 1}
|
||||
end
|
||||
|
||||
test "identifies an already safe report without needing removal" do
|
||||
input = "1 3 6 7 9\n"
|
||||
assert Day2.solve_part2(input) == {:ok, 1}
|
||||
end
|
||||
|
||||
test "identifies an unsafe report that can't be made safe" do
|
||||
input = "1 2 7 8 9\n"
|
||||
assert Day2.solve_part2(input) == {:ok, 0}
|
||||
end
|
||||
|
||||
test "handles empty input for part 2" do
|
||||
assert Day2.solve_part2("") == {:error, :no_valid_reports}
|
||||
end
|
||||
|
||||
test "handles invalid input format for part 2" do
|
||||
assert Day2.solve_part2("not numbers") == {:error, :invalid_format}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue