testing in Ruby the more right-er way
This commit is contained in:
parent
43db7108aa
commit
0b723f2ae0
@ -1,20 +1,14 @@
|
|||||||
|
require 'test/unit'
|
||||||
require 'sorting'
|
require 'sorting'
|
||||||
|
|
||||||
|
|
||||||
def test_insertion_sort
|
class TestSorting < Test::Unit::TestCase
|
||||||
|
def test_insertion_sort
|
||||||
tmpl = [8, 2, 4, 9, 3, 6]
|
tmpl = [8, 2, 4, 9, 3, 6]
|
||||||
a = Array.copy(tmpl)
|
a = Array.new(tmpl)
|
||||||
expected = [2, 3, 4, 6, 8, 9]
|
expected = [2, 3, 4, 6, 8, 9]
|
||||||
|
|
||||||
insertion_sort(a)
|
insertion_sort(a)
|
||||||
|
assert_equal(expected, a)
|
||||||
if expected != a
|
|
||||||
throw Exception.new 'OMG FAIL'
|
|
||||||
else
|
|
||||||
puts 'YAY!'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
test_insertion_sort
|
|
||||||
|
Loading…
Reference in New Issue
Block a user