Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save houmanka/6b589b98546f7513aef94da0ec34d6c4 to your computer and use it in GitHub Desktop.
Save houmanka/6b589b98546f7513aef94da0ec34d6c4 to your computer and use it in GitHub Desktop.
russian_peasant_multiplication_increment_test
defmodule RussianPeasantMultiplication.IncrementTest do
use ExUnit.Case
doctest RussianPeasantMultiplication.Increment
import Monad.Result
alias RussianPeasantMultiplication.Increment, as: RPM_Inc
test "max number must be a number" do
items = [ %{requested: "238", max_round: "4"},
%{requested: 238, max_round: "4"},
%{requested: "238", max_round: 4}
]
Enum.filter(items, fn(item) ->
res = RPM_Inc.increment(item.requested, item.max_round)
assert res.error == "Requested number and Max round must be numbers"
end)
end
test "max number must be a number greater than zero" do
res = RPM_Inc.increment(238, 0)
assert res.error == "Must be greater than zero"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment