|
|
|
@ -1,20 +1,14 @@
|
|
|
|
|
require 'test/unit'
|
|
|
|
|
require 'sorting'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_insertion_sort
|
|
|
|
|
tmpl = [8, 2, 4, 9, 3, 6]
|
|
|
|
|
a = Array.copy(tmpl)
|
|
|
|
|
expected = [2, 3, 4, 6, 8, 9]
|
|
|
|
|
class TestSorting < Test::Unit::TestCase
|
|
|
|
|
def test_insertion_sort
|
|
|
|
|
tmpl = [8, 2, 4, 9, 3, 6]
|
|
|
|
|
a = Array.new(tmpl)
|
|
|
|
|
expected = [2, 3, 4, 6, 8, 9]
|
|
|
|
|
|
|
|
|
|
insertion_sort(a)
|
|
|
|
|
|
|
|
|
|
if expected != a
|
|
|
|
|
throw Exception.new 'OMG FAIL'
|
|
|
|
|
else
|
|
|
|
|
puts 'YAY!'
|
|
|
|
|
insertion_sort(a)
|
|
|
|
|
assert_equal(expected, a)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_insertion_sort
|
|
|
|
|