1
exercism fetch elixir rail-fence-cipher

rail_fence_cipher_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
69
70
71
72
73
74
75
76
77
78
79
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
  Code.load_file("rail_fence_cipher.exs", __DIR__)
end

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

defmodule RailFenceCipherTest do
  use ExUnit.Case

  # @tag :pending
  test "encode with ending at the first rail" do
    assert RailFenceCipher.encode("XOXOXOXOXOXOXOXOXO", 2) == "XXXXXXXXXOOOOOOOOO"
  end

  @tag :pending
  test "encode with ending in the middle" do
    msg = "WEAREDISCOVEREDFLEEATONCE"
    assert RailFenceCipher.encode(msg, 3) == "WECRLTEERDSOEEFEAOCAIVDEN"
  end

  @tag :pending
  test "encode empty string" do
    assert RailFenceCipher.encode("", 4) == ""
  end

  @tag :pending
  test "encode a more diverse text" do
    msg = "The quick brown fox jumps over the lazy dog."
    cipher = "Tioxs aghucrwo p rtlzo.eqkbnfjmoeh yd   uve "
    assert RailFenceCipher.encode(msg, 4) == cipher
  end

  @tag :pending
  test "encode with one rail" do
    msg = "One rail, only one rail"
    assert RailFenceCipher.encode(msg, 1) == msg
  end

  @tag :pending
  test "encode letters of less than rails" do
    msg = "More rails than letters"
    assert RailFenceCipher.encode(msg, 24) == msg
  end

  @tag :pending
  test "decode full zigzag cipher" do
    cipher = "TEITELHDVLSNHDTIEIIEA"
    assert RailFenceCipher.decode(cipher, 3) == "THEDEVILISINTHEDETAIL"
  end

  @tag :pending
  test "decode with ending in the middle" do
    cipher = "EIEXMSMESAORIWSCE"
    assert RailFenceCipher.decode(cipher, 5) == "EXERCISMISAWESOME"
  end

  @tag :pending
  test "decode empty string" do
    assert RailFenceCipher.decode("", 4) == ""
  end

  @tag :pending
  test "decode with one rail" do
    assert RailFenceCipher.decode("ABCDEFGHIJKLMNOP", 1) == "ABCDEFGHIJKLMNOP"
  end

  @tag :pending
  test "decode letters of less than rails" do
    assert RailFenceCipher.decode("More rails than letters", 24) == "More rails than letters"
  end

  @tag :pending
  test "decode a more diverse text" do
    msg = "The quick brown fox jumps over the lazy dog."
    cipher = RailFenceCipher.encode(msg, 4)
    assert RailFenceCipher.decode(cipher, 4) == msg
  end
end