1
exercism fetch elixir minesweeper

minesweeper_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
64
65
66
67
68
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
  Code.load_file("minesweeper.exs", __DIR__)
end

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

defmodule MinesweeperTest do
  use ExUnit.Case

  defp clean(b), do: Enum.map(b, &String.replace(&1, ~r/[^*]/, " "))

  # @tag :pending
  test "zero size board" do
    b = []
    assert Minesweeper.annotate(clean(b)) == b
  end

  @tag :pending
  test "empty board" do
    b = ["   ",
         "   ",
         "   "]
    assert Minesweeper.annotate(clean(b)) == b
  end

  @tag :pending
  test "board full of mines" do
    b = ["***",
         "***",
         "***"]
    assert Minesweeper.annotate(clean(b)) == b
  end

  @tag :pending
  test "surrounded" do
    b = ["***",
         "*8*",
         "***"]
    assert Minesweeper.annotate(clean(b)) == b
  end

  @tag :pending
  test "horizontal line" do
    b = ["1*2*1"]
    assert Minesweeper.annotate(clean(b)) == b
  end

  @tag :pending
  test "vertical line" do
    b = ["1",
         "*",
         "2",
         "*",
         "1"]
    assert Minesweeper.annotate(clean(b)) == b
  end

  @tag :pending
  test "cross" do
    b = [" 2*2 ",
         "25*52",
         "*****",
         "25*52",
         " 2*2 "]
    assert Minesweeper.annotate(clean(b)) == b
  end
end