1
exercism fetch elixir pascals-triangle

pascals_triangle_test.exs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
  Code.load_file("pascals_triangle.exs", __DIR__)
end

ExUnit.start()
ExUnit.configure(exclude: :pending, trace: true)

defmodule PascalsTriangleTest do
  use ExUnit.Case

  # @tag pending
  test "one row" do
    assert PascalsTriangle.rows(1) == [[1]]
  end

  @tag :pending
  test "two rows" do
    assert PascalsTriangle.rows(2) == [[1], [1, 1]]
  end

  @tag :pending
  test "three rows" do
    assert PascalsTriangle.rows(3) == [[1], [1, 1], [1, 2, 1]]
  end

  @tag :pending
  test "fourth row" do
    assert List.last(PascalsTriangle.rows(4)) == [1, 3, 3, 1]
  end

  @tag :pending
  test "fifth row" do
    assert List.last(PascalsTriangle.rows(5)) == [1, 4, 6, 4, 1]
  end

  @tag :pending
  test "twentieth row" do
    expected = [
      1,
      19,
      171,
      969,
      3876,
      11_628,
      27_132,
      50_388,
      75_582,
      92_378,
      92_378,
      75_582,
      50_388,
      27_132,
      11_628,
      3876,
      969,
      171,
      19,
      1
    ]

    assert List.last(PascalsTriangle.rows(20)) == expected
  end
end