added basic tests for ISBN13

This commit is contained in:
Martin Frost 2015-05-27 08:15:21 +02:00
parent 00cd25485e
commit 0cfd44c402
2 changed files with 18 additions and 4 deletions

View File

@ -13,8 +13,11 @@ defmodule Isn.Base do
defdelegate blank?, to: Ecto.Type
def cast(nil), do: :error
def cast(isn), do: {:ok, to_string(isn)}
def load(isn), do: {:ok, to_string(isn)}
def dump(isn), do: {:ok, to_string(isn)}
end
end

View File

@ -1,7 +1,18 @@
defmodule Isn.ISBN13Test do
use ExUnit.Case
use ExUnit.Case, async: true
# dump
# cast
# load
@test_isbn "978-1-937785-58-1"
test "cast" do
assert Isn.ISBN13.cast(@test_isbn) == {:ok, @test_isbn}
assert Isn.ISBN13.cast(nil) == :error
end
test "load" do
assert Isn.ISBN13.load(@test_isbn) == {:ok, @test_isbn}
end
test "dump" do
assert Isn.ISBN13.dump(@test_isbn) == {:ok, @test_isbn}
end
end