Skip to content

Instantly share code, notes, and snippets.

@koga1020
Last active January 19, 2020 04:04
Show Gist options
  • Save koga1020/9f79d5942153e853fb80cd63c5d0e24b to your computer and use it in GitHub Desktop.
Save koga1020/9f79d5942153e853fb80cd63c5d0e24b to your computer and use it in GitHub Desktop.
defmodule AggregaterTest do
use ExUnit.Case
doctest Aggregater
describe "test for Aggregater.counter" do
test "シンプルなケース" do
assert Aggregater.counter(["A", "B", "C", "D"]) == %{"A" => 1, "B" => 1, "C" => 1, "D" => 1}
end
test "重複した値がうまくカウントされているか" do
assert Aggregater.counter(["A", "B", "A", "C"]) == %{"A" => 2, "B" => 1, "C" => 1}
end
test "リストが空の場合" do
assert Aggregater.counter([]) == %{}
end
test "複数の値が重複する場合" do
assert Aggregater.counter(["A", "B", "A", "C", "D", "C", "E", "F", "D", "F", "G"]) == %{
"A" => 2,
"B" => 1,
"C" => 2,
"D" => 2,
"E" => 1,
"F" => 2,
"G" => 1
}
end
test "重複の発生が3回以上" do
assert Aggregater.counter(["A", "A", "A"]) == %{"A" => 3}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment