1
0
Fork 0

chore: stand up puzzle solver, puzzle case

This commit is contained in:
Zach Perrault 2021-11-03 07:39:51 -04:00
parent 25b4401910
commit 9726431599
No known key found for this signature in database
GPG key ID: 2F7DFF830420DC52
4 changed files with 34 additions and 21 deletions

View file

@ -2,17 +2,4 @@ defmodule AdventOfCode do
@moduledoc """
Documentation for `AdventOfCode`.
"""
@doc """
Hello world.
## Examples
iex> AdventOfCode.hello()
:world
"""
def hello do
:world
end
end

View 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

View file

@ -1,8 +0,0 @@
defmodule AdventOfCodeTest do
use ExUnit.Case
doctest AdventOfCode
test "greets the world" do
assert AdventOfCode.hello() == :world
end
end

View 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