Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions exercises/practice/roman-numerals/.meta/test_template.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'minitest/autorun'
require_relative 'roman_numerals'

class RomanNumeralsTest < Minitest::Test
<% json["cases"].each do |cases| %>
def test_<%= underscore(cases["description"]) %>
<%= skip? %>
actual = <%= cases["input"]["number"] %>.to_roman
expected = '<%= cases["expected"] %>'
assert_equal expected, actual
end
<% end %>
end
139 changes: 99 additions & 40 deletions exercises/practice/roman-numerals/roman_numerals_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,131 +4,190 @@
class RomanNumeralsTest < Minitest::Test
def test_1_is_i
# skip
assert_equal "I", 1.to_roman
actual = 1.to_roman
expected = 'I'
assert_equal expected, actual
end

def test_2_is_ii
skip
assert_equal "II", 2.to_roman
actual = 2.to_roman
expected = 'II'
assert_equal expected, actual
end

def test_3_is_iii
skip
assert_equal "III", 3.to_roman
actual = 3.to_roman
expected = 'III'
assert_equal expected, actual
end

def test_4_is_iv
skip
assert_equal "IV", 4.to_roman
actual = 4.to_roman
expected = 'IV'
assert_equal expected, actual
end

def test_5_is_v
skip
assert_equal "V", 5.to_roman
actual = 5.to_roman
expected = 'V'
assert_equal expected, actual
end

def test_6_is_vi
skip
assert_equal "VI", 6.to_roman
actual = 6.to_roman
expected = 'VI'
assert_equal expected, actual
end

def test_9_is_ix
skip
assert_equal "IX", 9.to_roman
actual = 9.to_roman
expected = 'IX'
assert_equal expected, actual
end

def test_16_is_xvi
skip
actual = 16.to_roman
expected = 'XVI'
assert_equal expected, actual
end

def test_27_is_xxvii
skip
assert_equal "XXVII", 27.to_roman
actual = 27.to_roman
expected = 'XXVII'
assert_equal expected, actual
end

def test_48_is_xlviii
skip
assert_equal "XLVIII", 48.to_roman
actual = 48.to_roman
expected = 'XLVIII'
assert_equal expected, actual
end

def test_49_is_xlix
skip
assert_equal "XLIX", 49.to_roman
actual = 49.to_roman
expected = 'XLIX'
assert_equal expected, actual
end

def test_59_is_lix
skip
assert_equal "LIX", 59.to_roman
actual = 59.to_roman
expected = 'LIX'
assert_equal expected, actual
end

def test_93_is_xciii
def test_66_is_lxvi
skip
assert_equal "XCIII", 93.to_roman
actual = 66.to_roman
expected = 'LXVI'
assert_equal expected, actual
end

def test_141_is_cxli
def test_93_is_xciii
skip
assert_equal "CXLI", 141.to_roman
actual = 93.to_roman
expected = 'XCIII'
assert_equal expected, actual
end

def test_163_is_clxiii
def test_141_is_cxli
skip
assert_equal "CLXIII", 163.to_roman
actual = 141.to_roman
expected = 'CXLI'
assert_equal expected, actual
end

def test_402_is_cdii
def test_163_is_clxiii
skip
assert_equal "CDII", 402.to_roman
actual = 163.to_roman
expected = 'CLXIII'
assert_equal expected, actual
end

def test_575_is_dlxxv
def test_166_is_clxvi
skip
assert_equal "DLXXV", 575.to_roman
actual = 166.to_roman
expected = 'CLXVI'
assert_equal expected, actual
end

def test_911_is_cmxi
def test_402_is_cdii
skip
assert_equal "CMXI", 911.to_roman
actual = 402.to_roman
expected = 'CDII'
assert_equal expected, actual
end

def test_1024_is_mxxiv
def test_575_is_dlxxv
skip
assert_equal "MXXIV", 1024.to_roman
actual = 575.to_roman
expected = 'DLXXV'
assert_equal expected, actual
end

def test_3000_is_mmm
def test_666_is_dclxvi
skip
assert_equal "MMM", 3000.to_roman
actual = 666.to_roman
expected = 'DCLXVI'
assert_equal expected, actual
end

def test_16_is_xvi
def test_911_is_cmxi
skip
assert_equal "XVI", 16.to_roman
actual = 911.to_roman
expected = 'CMXI'
assert_equal expected, actual
end

def test_66_is_lxvi
def test_1024_is_mxxiv
skip
assert_equal "LXVI", 66.to_roman
actual = 1024.to_roman
expected = 'MXXIV'
assert_equal expected, actual
end

def test_166_is_clxvi
def test_1666_is_mdclxvi
skip
assert_equal "CLXVI", 166.to_roman
actual = 1666.to_roman
expected = 'MDCLXVI'
assert_equal expected, actual
end

def test_666_is_dclxvi
def test_3000_is_mmm
skip
assert_equal "DCLXVI", 666.to_roman
actual = 3000.to_roman
expected = 'MMM'
assert_equal expected, actual
end

def test_1666_is_mdclxvi
def test_3001_is_mmmi
skip
assert_equal "MDCLXVI", 1666.to_roman
actual = 3001.to_roman
expected = 'MMMI'
assert_equal expected, actual
end

def test_3001_is_mmmi
def test_3888_is_mmmdccclxxxviii
skip
assert_equal "MMMI", 3001.to_roman
actual = 3888.to_roman
expected = 'MMMDCCCLXXXVIII'
assert_equal expected, actual
end

def test_3999_is_mmmcmxcix
skip
assert_equal "MMMCMXCIX", 3999.to_roman
actual = 3999.to_roman
expected = 'MMMCMXCIX'
assert_equal expected, actual
end
end
13 changes: 13 additions & 0 deletions exercises/practice/rotational-cipher/.meta/test_template.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'minitest/autorun'
require_relative 'rotational_cipher'

class RotationalCipherTest < Minitest::Test
<% json["cases"].each do |cases| %>
def test_<%= underscore(cases["description"]) %>
<%= skip? %>
actual = RotationalCipher.rotate("<%= cases["input"]["text"] %>", <%= cases["input"]["shiftKey"] %>)
expected = "<%= cases["expected"] %>"
assert_equal expected, actual
end
<% end %>
end
41 changes: 30 additions & 11 deletions exercises/practice/rotational-cipher/rotational_cipher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,71 @@
class RotationalCipherTest < Minitest::Test
def test_rotate_a_by_0_same_output_as_input
# skip
assert_equal "a", RotationalCipher.rotate("a", 0)
actual = RotationalCipher.rotate("a", 0)
expected = "a"
assert_equal expected, actual
end

def test_rotate_a_by_1
skip
assert_equal "b", RotationalCipher.rotate("a", 1)
actual = RotationalCipher.rotate("a", 1)
expected = "b"
assert_equal expected, actual
end

def test_rotate_a_by_26_same_output_as_input
skip
assert_equal "a", RotationalCipher.rotate("a", 26)
actual = RotationalCipher.rotate("a", 26)
expected = "a"
assert_equal expected, actual
end

def test_rotate_m_by_13
skip
assert_equal "z", RotationalCipher.rotate("m", 13)
actual = RotationalCipher.rotate("m", 13)
expected = "z"
assert_equal expected, actual
end

def test_rotate_n_by_13_with_wrap_around_alphabet
skip
assert_equal "a", RotationalCipher.rotate("n", 13)
actual = RotationalCipher.rotate("n", 13)
expected = "a"
assert_equal expected, actual
end

def test_rotate_capital_letters
skip
assert_equal "TRL", RotationalCipher.rotate("OMG", 5)
actual = RotationalCipher.rotate("OMG", 5)
expected = "TRL"
assert_equal expected, actual
end

def test_rotate_spaces
skip
assert_equal "T R L", RotationalCipher.rotate("O M G", 5)
actual = RotationalCipher.rotate("O M G", 5)
expected = "T R L"
assert_equal expected, actual
end

def test_rotate_numbers
skip
assert_equal "Xiwxmrk 1 2 3 xiwxmrk", RotationalCipher.rotate("Testing 1 2 3 testing", 4)
actual = RotationalCipher.rotate("Testing 1 2 3 testing", 4)
expected = "Xiwxmrk 1 2 3 xiwxmrk"
assert_equal expected, actual
end

def test_rotate_punctuation
skip
assert_equal "Gzo'n zvo, Bmviyhv!", RotationalCipher.rotate("Let's eat, Grandma!", 21)
actual = RotationalCipher.rotate("Let's eat, Grandma!", 21)
expected = "Gzo'n zvo, Bmviyhv!"
assert_equal expected, actual
end

def test_rotate_all_letters
skip
assert_equal "Gur dhvpx oebja sbk whzcf bire gur ynml qbt.",
RotationalCipher.rotate("The quick brown fox jumps over the lazy dog.", 13)
actual = RotationalCipher.rotate("The quick brown fox jumps over the lazy dog.", 13)
expected = "Gur dhvpx oebja sbk whzcf bire gur ynml qbt."
assert_equal expected, actual
end
end
21 changes: 21 additions & 0 deletions exercises/practice/run-length-encoding/.meta/test_template.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'minitest/autorun'
require_relative 'run_length_encoding'

class RunLengthEncodingTest < Minitest::Test
<% json["cases"].each do |cases| %>
<% cases["cases"].each do |sub_case| %>
def test_<%= sub_case["property"] %>_<%= underscore(sub_case["description"]) %>
<%= skip? %>
<%- if sub_case["property"] == "consistency" -%>
actual = RunLengthEncoding.decode(RunLengthEncoding.encode('<%= sub_case["input"]["string"] %>'))
expected = '<%= sub_case["expected"] %>'
assert_equal expected, actual
<%- else -%>
actual = RunLengthEncoding.<%= sub_case["property"] %>('<%= sub_case["input"]["string"] %>')
expected = '<%= sub_case["expected"] %>'
assert_equal expected, actual
<%- end -%>
end
<% end %>
<% end %>
end
Loading