chore: stand up puzzle solver, puzzle case
This commit is contained in:
parent
25b4401910
commit
9726431599
4 changed files with 34 additions and 21 deletions
2021
|
@ -2,17 +2,4 @@ defmodule AdventOfCode do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Documentation for `AdventOfCode`.
|
Documentation for `AdventOfCode`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@doc """
|
|
||||||
Hello world.
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
iex> AdventOfCode.hello()
|
|
||||||
:world
|
|
||||||
|
|
||||||
"""
|
|
||||||
def hello do
|
|
||||||
:world
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
16
2021/lib/advent_of_code/puzzle_solver.ex
Normal file
16
2021/lib/advent_of_code/puzzle_solver.ex
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
defmodule AdventOfCode.PuzzleSolver do
|
||||||
|
@moduledoc """
|
||||||
|
Behaviour for a puzzle solution.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Given the input as a stream, return the solution as a string
|
||||||
|
"""
|
||||||
|
@callback solve(IO.Stream.t()) :: String.t()
|
||||||
|
|
||||||
|
defmacro __using__(_) do
|
||||||
|
quote do
|
||||||
|
@behaviour AdventOfCode.PuzzleSolver
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,8 +0,0 @@
|
||||||
defmodule AdventOfCodeTest do
|
|
||||||
use ExUnit.Case
|
|
||||||
doctest AdventOfCode
|
|
||||||
|
|
||||||
test "greets the world" do
|
|
||||||
assert AdventOfCode.hello() == :world
|
|
||||||
end
|
|
||||||
end
|
|
18
2021/test/support/puzzle_case.ex
Normal file
18
2021/test/support/puzzle_case.ex
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
defmodule AdventOfCode.PuzzleCase do
|
||||||
|
@moduledoc """
|
||||||
|
Defines tests for an `AdventOfCode.PuzzleSolver` module.
|
||||||
|
"""
|
||||||
|
|
||||||
|
use ExUnit.CaseTemplate
|
||||||
|
|
||||||
|
using module: module do
|
||||||
|
quote bind_quoted: [module: module] do
|
||||||
|
@module module
|
||||||
|
|
||||||
|
defp assert_solution(input, desired_output) do
|
||||||
|
actual_output = @module.run(input)
|
||||||
|
assert actual_output == desired_output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue