Created
April 1, 2020 10:00
-
-
Save houmanka/f8b50ac99ceaf117450d1c8182be74f0 to your computer and use it in GitHub Desktop.
RussianPeasantMultiplicationTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule RussianPeasantMultiplicationTest do | |
use ExUnit.Case | |
doctest RussianPeasantMultiplication | |
alias RussianPeasantMultiplication, as: RPM | |
test "Should return errors if inputs are incorrect" do | |
[ | |
%{first: "we", second: "adf"}, | |
%{first: 13, second: "adf"}, | |
%{first: "we", second: 238}, | |
%{first: nil, second: 238}, | |
%{first: "we", second: nil}, | |
] | |
|> Enum.filter(fn(input) -> | |
res = RPM.multiply(input.first, input.second) | |
assert res == "Must be number greater than zero" | |
end) | |
end | |
test "Should return errors if inputs are less than zero" do | |
[ | |
%{first: 0, second: -1 }, | |
%{first: -1, second: 0}, | |
%{first: 0, second: 0} | |
] | |
|> Enum.filter(fn(input) -> | |
res = RPM.multiply(input.first, input.second) | |
assert res == "Must be number greater than zero" | |
end) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment