Skip to content

Commit ce3f47f

Browse files
authored
Add templates for exercises batch 10 (#1795)
1 parent d941985 commit ce3f47f

13 files changed

Lines changed: 418 additions & 178 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'minitest/autorun'
2+
require_relative 'roman_numerals'
3+
4+
class RomanNumeralsTest < Minitest::Test
5+
<% json["cases"].each do |cases| %>
6+
def test_<%= underscore(cases["description"]) %>
7+
<%= skip? %>
8+
actual = <%= cases["input"]["number"] %>.to_roman
9+
expected = '<%= cases["expected"] %>'
10+
assert_equal expected, actual
11+
end
12+
<% end %>
13+
end

exercises/practice/roman-numerals/roman_numerals_test.rb

Lines changed: 99 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,131 +4,190 @@
44
class RomanNumeralsTest < Minitest::Test
55
def test_1_is_i
66
# skip
7-
assert_equal "I", 1.to_roman
7+
actual = 1.to_roman
8+
expected = 'I'
9+
assert_equal expected, actual
810
end
911

1012
def test_2_is_ii
1113
skip
12-
assert_equal "II", 2.to_roman
14+
actual = 2.to_roman
15+
expected = 'II'
16+
assert_equal expected, actual
1317
end
1418

1519
def test_3_is_iii
1620
skip
17-
assert_equal "III", 3.to_roman
21+
actual = 3.to_roman
22+
expected = 'III'
23+
assert_equal expected, actual
1824
end
1925

2026
def test_4_is_iv
2127
skip
22-
assert_equal "IV", 4.to_roman
28+
actual = 4.to_roman
29+
expected = 'IV'
30+
assert_equal expected, actual
2331
end
2432

2533
def test_5_is_v
2634
skip
27-
assert_equal "V", 5.to_roman
35+
actual = 5.to_roman
36+
expected = 'V'
37+
assert_equal expected, actual
2838
end
2939

3040
def test_6_is_vi
3141
skip
32-
assert_equal "VI", 6.to_roman
42+
actual = 6.to_roman
43+
expected = 'VI'
44+
assert_equal expected, actual
3345
end
3446

3547
def test_9_is_ix
3648
skip
37-
assert_equal "IX", 9.to_roman
49+
actual = 9.to_roman
50+
expected = 'IX'
51+
assert_equal expected, actual
52+
end
53+
54+
def test_16_is_xvi
55+
skip
56+
actual = 16.to_roman
57+
expected = 'XVI'
58+
assert_equal expected, actual
3859
end
3960

4061
def test_27_is_xxvii
4162
skip
42-
assert_equal "XXVII", 27.to_roman
63+
actual = 27.to_roman
64+
expected = 'XXVII'
65+
assert_equal expected, actual
4366
end
4467

4568
def test_48_is_xlviii
4669
skip
47-
assert_equal "XLVIII", 48.to_roman
70+
actual = 48.to_roman
71+
expected = 'XLVIII'
72+
assert_equal expected, actual
4873
end
4974

5075
def test_49_is_xlix
5176
skip
52-
assert_equal "XLIX", 49.to_roman
77+
actual = 49.to_roman
78+
expected = 'XLIX'
79+
assert_equal expected, actual
5380
end
5481

5582
def test_59_is_lix
5683
skip
57-
assert_equal "LIX", 59.to_roman
84+
actual = 59.to_roman
85+
expected = 'LIX'
86+
assert_equal expected, actual
5887
end
5988

60-
def test_93_is_xciii
89+
def test_66_is_lxvi
6190
skip
62-
assert_equal "XCIII", 93.to_roman
91+
actual = 66.to_roman
92+
expected = 'LXVI'
93+
assert_equal expected, actual
6394
end
6495

65-
def test_141_is_cxli
96+
def test_93_is_xciii
6697
skip
67-
assert_equal "CXLI", 141.to_roman
98+
actual = 93.to_roman
99+
expected = 'XCIII'
100+
assert_equal expected, actual
68101
end
69102

70-
def test_163_is_clxiii
103+
def test_141_is_cxli
71104
skip
72-
assert_equal "CLXIII", 163.to_roman
105+
actual = 141.to_roman
106+
expected = 'CXLI'
107+
assert_equal expected, actual
73108
end
74109

75-
def test_402_is_cdii
110+
def test_163_is_clxiii
76111
skip
77-
assert_equal "CDII", 402.to_roman
112+
actual = 163.to_roman
113+
expected = 'CLXIII'
114+
assert_equal expected, actual
78115
end
79116

80-
def test_575_is_dlxxv
117+
def test_166_is_clxvi
81118
skip
82-
assert_equal "DLXXV", 575.to_roman
119+
actual = 166.to_roman
120+
expected = 'CLXVI'
121+
assert_equal expected, actual
83122
end
84123

85-
def test_911_is_cmxi
124+
def test_402_is_cdii
86125
skip
87-
assert_equal "CMXI", 911.to_roman
126+
actual = 402.to_roman
127+
expected = 'CDII'
128+
assert_equal expected, actual
88129
end
89130

90-
def test_1024_is_mxxiv
131+
def test_575_is_dlxxv
91132
skip
92-
assert_equal "MXXIV", 1024.to_roman
133+
actual = 575.to_roman
134+
expected = 'DLXXV'
135+
assert_equal expected, actual
93136
end
94137

95-
def test_3000_is_mmm
138+
def test_666_is_dclxvi
96139
skip
97-
assert_equal "MMM", 3000.to_roman
140+
actual = 666.to_roman
141+
expected = 'DCLXVI'
142+
assert_equal expected, actual
98143
end
99144

100-
def test_16_is_xvi
145+
def test_911_is_cmxi
101146
skip
102-
assert_equal "XVI", 16.to_roman
147+
actual = 911.to_roman
148+
expected = 'CMXI'
149+
assert_equal expected, actual
103150
end
104151

105-
def test_66_is_lxvi
152+
def test_1024_is_mxxiv
106153
skip
107-
assert_equal "LXVI", 66.to_roman
154+
actual = 1024.to_roman
155+
expected = 'MXXIV'
156+
assert_equal expected, actual
108157
end
109158

110-
def test_166_is_clxvi
159+
def test_1666_is_mdclxvi
111160
skip
112-
assert_equal "CLXVI", 166.to_roman
161+
actual = 1666.to_roman
162+
expected = 'MDCLXVI'
163+
assert_equal expected, actual
113164
end
114165

115-
def test_666_is_dclxvi
166+
def test_3000_is_mmm
116167
skip
117-
assert_equal "DCLXVI", 666.to_roman
168+
actual = 3000.to_roman
169+
expected = 'MMM'
170+
assert_equal expected, actual
118171
end
119172

120-
def test_1666_is_mdclxvi
173+
def test_3001_is_mmmi
121174
skip
122-
assert_equal "MDCLXVI", 1666.to_roman
175+
actual = 3001.to_roman
176+
expected = 'MMMI'
177+
assert_equal expected, actual
123178
end
124179

125-
def test_3001_is_mmmi
180+
def test_3888_is_mmmdccclxxxviii
126181
skip
127-
assert_equal "MMMI", 3001.to_roman
182+
actual = 3888.to_roman
183+
expected = 'MMMDCCCLXXXVIII'
184+
assert_equal expected, actual
128185
end
129186

130187
def test_3999_is_mmmcmxcix
131188
skip
132-
assert_equal "MMMCMXCIX", 3999.to_roman
189+
actual = 3999.to_roman
190+
expected = 'MMMCMXCIX'
191+
assert_equal expected, actual
133192
end
134193
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'minitest/autorun'
2+
require_relative 'rotational_cipher'
3+
4+
class RotationalCipherTest < Minitest::Test
5+
<% json["cases"].each do |cases| %>
6+
def test_<%= underscore(cases["description"]) %>
7+
<%= skip? %>
8+
actual = RotationalCipher.rotate("<%= cases["input"]["text"] %>", <%= cases["input"]["shiftKey"] %>)
9+
expected = "<%= cases["expected"] %>"
10+
assert_equal expected, actual
11+
end
12+
<% end %>
13+
end

exercises/practice/rotational-cipher/rotational_cipher_test.rb

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,71 @@
44
class RotationalCipherTest < Minitest::Test
55
def test_rotate_a_by_0_same_output_as_input
66
# skip
7-
assert_equal "a", RotationalCipher.rotate("a", 0)
7+
actual = RotationalCipher.rotate("a", 0)
8+
expected = "a"
9+
assert_equal expected, actual
810
end
911

1012
def test_rotate_a_by_1
1113
skip
12-
assert_equal "b", RotationalCipher.rotate("a", 1)
14+
actual = RotationalCipher.rotate("a", 1)
15+
expected = "b"
16+
assert_equal expected, actual
1317
end
1418

1519
def test_rotate_a_by_26_same_output_as_input
1620
skip
17-
assert_equal "a", RotationalCipher.rotate("a", 26)
21+
actual = RotationalCipher.rotate("a", 26)
22+
expected = "a"
23+
assert_equal expected, actual
1824
end
1925

2026
def test_rotate_m_by_13
2127
skip
22-
assert_equal "z", RotationalCipher.rotate("m", 13)
28+
actual = RotationalCipher.rotate("m", 13)
29+
expected = "z"
30+
assert_equal expected, actual
2331
end
2432

2533
def test_rotate_n_by_13_with_wrap_around_alphabet
2634
skip
27-
assert_equal "a", RotationalCipher.rotate("n", 13)
35+
actual = RotationalCipher.rotate("n", 13)
36+
expected = "a"
37+
assert_equal expected, actual
2838
end
2939

3040
def test_rotate_capital_letters
3141
skip
32-
assert_equal "TRL", RotationalCipher.rotate("OMG", 5)
42+
actual = RotationalCipher.rotate("OMG", 5)
43+
expected = "TRL"
44+
assert_equal expected, actual
3345
end
3446

3547
def test_rotate_spaces
3648
skip
37-
assert_equal "T R L", RotationalCipher.rotate("O M G", 5)
49+
actual = RotationalCipher.rotate("O M G", 5)
50+
expected = "T R L"
51+
assert_equal expected, actual
3852
end
3953

4054
def test_rotate_numbers
4155
skip
42-
assert_equal "Xiwxmrk 1 2 3 xiwxmrk", RotationalCipher.rotate("Testing 1 2 3 testing", 4)
56+
actual = RotationalCipher.rotate("Testing 1 2 3 testing", 4)
57+
expected = "Xiwxmrk 1 2 3 xiwxmrk"
58+
assert_equal expected, actual
4359
end
4460

4561
def test_rotate_punctuation
4662
skip
47-
assert_equal "Gzo'n zvo, Bmviyhv!", RotationalCipher.rotate("Let's eat, Grandma!", 21)
63+
actual = RotationalCipher.rotate("Let's eat, Grandma!", 21)
64+
expected = "Gzo'n zvo, Bmviyhv!"
65+
assert_equal expected, actual
4866
end
4967

5068
def test_rotate_all_letters
5169
skip
52-
assert_equal "Gur dhvpx oebja sbk whzcf bire gur ynml qbt.",
53-
RotationalCipher.rotate("The quick brown fox jumps over the lazy dog.", 13)
70+
actual = RotationalCipher.rotate("The quick brown fox jumps over the lazy dog.", 13)
71+
expected = "Gur dhvpx oebja sbk whzcf bire gur ynml qbt."
72+
assert_equal expected, actual
5473
end
5574
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require 'minitest/autorun'
2+
require_relative 'run_length_encoding'
3+
4+
class RunLengthEncodingTest < Minitest::Test
5+
<% json["cases"].each do |cases| %>
6+
<% cases["cases"].each do |sub_case| %>
7+
def test_<%= sub_case["property"] %>_<%= underscore(sub_case["description"]) %>
8+
<%= skip? %>
9+
<%- if sub_case["property"] == "consistency" -%>
10+
actual = RunLengthEncoding.decode(RunLengthEncoding.encode('<%= sub_case["input"]["string"] %>'))
11+
expected = '<%= sub_case["expected"] %>'
12+
assert_equal expected, actual
13+
<%- else -%>
14+
actual = RunLengthEncoding.<%= sub_case["property"] %>('<%= sub_case["input"]["string"] %>')
15+
expected = '<%= sub_case["expected"] %>'
16+
assert_equal expected, actual
17+
<%- end -%>
18+
end
19+
<% end %>
20+
<% end %>
21+
end

0 commit comments

Comments
 (0)