-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathME_test.rb
39 lines (32 loc) · 1018 Bytes
/
ME_test.rb
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
require 'test/unit'
def me file, input = []
`ruby ME.rb #{file} #{input.join(' ')}`.split.map(&:to_i)
end
class TestExamples < Test::Unit::TestCase
@@sorted_array = (-10..10).to_a
@@shuffled_array = @@sorted_array.shuffle(random: Random.new(0))
def test_simple
out = me 'examples/simple', [22, 34]
assert_equal out, [56, -12, 748, 0]
end
def test_sum_product
out = me 'examples/sum_product', [3, 23, 2, 12]
assert_equal out, [37, 552]
end
def test_selection_sort
out = me 'examples/selection_sort', [@@shuffled_array.length, *@@shuffled_array]
assert_equal out, @@sorted_array
out = me 'examples/selection_sort', [0]
assert_equal out, []
end
def test_bubble_sort
out = me 'examples/bubble_sort', [@@shuffled_array.length, *@@shuffled_array]
assert_equal out, @@sorted_array
out = me 'examples/bubble_sort', [0]
assert_equal out, []
end
def test_subroutines
out = me 'examples/subroutines'
assert_equal out, [100, 400]
end
end