feat: Add test for part 2 README example in Day03

This commit is contained in:
Ruidy (aider) 2024-12-03 14:24:35 +01:00 committed by Ruidy
parent e1f4afe639
commit bdb91371cd
No known key found for this signature in database
GPG key ID: E00F51288CB857CC

View file

@ -8,7 +8,7 @@ defmodule AdventCode2024.Solutions.Day03Test do
end end
test "returns error for invalid file" do test "returns error for invalid file" do
assert Day03.solve("nonexistent.txt") == {:error, :enoent} assert Day03.solve("priv/nonexistent.txt") == {:error, :enoent}
end end
test "handles single valid multiplication" do test "handles single valid multiplication" do
@ -48,7 +48,7 @@ defmodule AdventCode2024.Solutions.Day03Test do
end end
test "returns error for invalid file" do test "returns error for invalid file" do
assert Day03.solve_part2("nonexistent.txt") == {:error, :enoent} assert Day03.solve_part2("priv/nonexistent.txt") == {:error, :enoent}
end end
test "handles single multiplication with do/don't controls" do test "handles single multiplication with do/don't controls" do
@ -73,7 +73,12 @@ defmodule AdventCode2024.Solutions.Day03Test do
test "ignores invalid control instructions" do test "ignores invalid control instructions" do
input = "mul(2,4)dont()mul(5,5)doo()mul(3,3)" input = "mul(2,4)dont()mul(5,5)doo()mul(3,3)"
assert Day03.solve_part2(input) == {:ok, 38} assert Day03.solve_part2(input) == {:ok, 42}
end
test "solves README example for part 2" do
input = "xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))"
assert Day03.solve_part2(input) == {:ok, 48}
end end
end end
end end