added basic tests for ISBN13
This commit is contained in:
parent
00cd25485e
commit
0cfd44c402
|
|
@ -13,8 +13,11 @@ defmodule Isn.Base do
|
||||||
|
|
||||||
defdelegate blank?, to: Ecto.Type
|
defdelegate blank?, to: Ecto.Type
|
||||||
|
|
||||||
|
def cast(nil), do: :error
|
||||||
def cast(isn), do: {:ok, to_string(isn)}
|
def cast(isn), do: {:ok, to_string(isn)}
|
||||||
|
|
||||||
def load(isn), do: {:ok, to_string(isn)}
|
def load(isn), do: {:ok, to_string(isn)}
|
||||||
|
|
||||||
def dump(isn), do: {:ok, to_string(isn)}
|
def dump(isn), do: {:ok, to_string(isn)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,18 @@
|
||||||
defmodule Isn.ISBN13Test do
|
defmodule Isn.ISBN13Test do
|
||||||
use ExUnit.Case
|
use ExUnit.Case, async: true
|
||||||
|
|
||||||
# dump
|
@test_isbn "978-1-937785-58-1"
|
||||||
# cast
|
|
||||||
# load
|
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
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue