proverb
This commit is contained in:
78
elixir/proverb/test/proverb_test.exs
Normal file
78
elixir/proverb/test/proverb_test.exs
Normal file
@@ -0,0 +1,78 @@
|
||||
defmodule ProverbTest do
|
||||
use ExUnit.Case
|
||||
|
||||
test "zero pieces" do
|
||||
strings = []
|
||||
output = Proverb.recite(strings)
|
||||
expected = ""
|
||||
|
||||
assert output == expected
|
||||
end
|
||||
|
||||
test "one piece" do
|
||||
strings = ["nail"]
|
||||
output = Proverb.recite(strings)
|
||||
|
||||
expected = """
|
||||
And all for the want of a nail.
|
||||
"""
|
||||
|
||||
assert output == expected
|
||||
end
|
||||
|
||||
test "two pieces" do
|
||||
strings = ["nail", "shoe"]
|
||||
output = Proverb.recite(strings)
|
||||
|
||||
expected = """
|
||||
For want of a nail the shoe was lost.
|
||||
And all for the want of a nail.
|
||||
"""
|
||||
|
||||
assert output == expected
|
||||
end
|
||||
|
||||
test "three pieces" do
|
||||
strings = ["nail", "shoe", "horse"]
|
||||
output = Proverb.recite(strings)
|
||||
|
||||
expected = """
|
||||
For want of a nail the shoe was lost.
|
||||
For want of a shoe the horse was lost.
|
||||
And all for the want of a nail.
|
||||
"""
|
||||
|
||||
assert output == expected
|
||||
end
|
||||
|
||||
test "full proverb" do
|
||||
strings = ["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"]
|
||||
output = Proverb.recite(strings)
|
||||
|
||||
expected = """
|
||||
For want of a nail the shoe was lost.
|
||||
For want of a shoe the horse was lost.
|
||||
For want of a horse the rider was lost.
|
||||
For want of a rider the message was lost.
|
||||
For want of a message the battle was lost.
|
||||
For want of a battle the kingdom was lost.
|
||||
And all for the want of a nail.
|
||||
"""
|
||||
|
||||
assert output == expected
|
||||
end
|
||||
|
||||
test "four pieces modernized" do
|
||||
strings = ["pin", "gun", "soldier", "battle"]
|
||||
output = Proverb.recite(strings)
|
||||
|
||||
expected = """
|
||||
For want of a pin the gun was lost.
|
||||
For want of a gun the soldier was lost.
|
||||
For want of a soldier the battle was lost.
|
||||
And all for the want of a pin.
|
||||
"""
|
||||
|
||||
assert output == expected
|
||||
end
|
||||
end
|
||||
2
elixir/proverb/test/test_helper.exs
Normal file
2
elixir/proverb/test/test_helper.exs
Normal file
@@ -0,0 +1,2 @@
|
||||
ExUnit.start()
|
||||
ExUnit.configure(exclude: :pending, trace: true)
|
||||
Reference in New Issue
Block a user