Created
August 1, 2017 17:52
-
-
Save ronualdo/66e2339a17a7c33229ca61bda977765e to your computer and use it in GitHub Desktop.
This file contains 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 FlattenTest do | |
use ExUnit.Case | |
doctest Flatten | |
test "flats an empty array" do | |
assert Flatten.flat([]) == [] | |
end | |
test "flats an array with just one element" do | |
assert Flatten.flat([1]) == [1] | |
end | |
test "flats an array with two elements" do | |
assert Flatten.flat([1, 2]) == [1, 2] | |
end | |
test "flats an array that contains an empty array" do | |
assert Flatten.flat([[]]) == [] | |
end | |
test "flats an array that contains numbers and an empty array" do | |
assert Flatten.flat([1, 2, [3], 4]) == [1, 2, 3, 4] | |
end | |
test "flats a number array that contains another number array" do | |
assert Flatten.flat([1, 2, [1, 2, 3], 4]) == [1, 2, 1, 2, 3, 4] | |
end | |
test "flats a number array with an empty multi index array" do | |
assert Flatten.flat([1, 2, 3, [[[]]], 4]) == [1, 2, 3, 4] | |
end | |
test "flats a number array with anothe multi index array" do | |
assert Flatten.flat([1, 2, [[[3]]], 4]) == [1, 2, 3, 4] | |
end | |
test "flats an array with number arrays" do | |
assert Flatten.flat([[1], [2, 3], [[4, 5, [[6]]]]]) == [1, 2, 3, 4, 5, 6] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment