Last active
August 20, 2019 19:53
-
-
Save grufino/aa8a97d29f61bda9e2a501c7dad83f5e 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
property "index number is always it's average in all indexes" do | |
check all size <- integer(1..100), | |
number_lists <- list_of(number_list(size), min_length: 1, max_length: 100) do | |
# since this test is based on index it also tests that ordering is maintained | |
Enum.map(1..(size - 1), fn index -> | |
index_avg = | |
Enum.map(number_lists, fn number_list -> Enum.at(number_list, index) end) | |
|> Enum.filter(fn value -> value != 0 && value != nil end) | |
|> Math.Enum.mean() | |
assert MissingData.average_list(number_lists) |> Enum.at(index) == index_avg | |
end) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment