mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-11-16 19:50:00 +01:00
Add tests for heap sort
This commit is contained in:
parent
81bd32aed0
commit
ac449e637c
2 changed files with 17 additions and 3 deletions
|
@ -27,6 +27,9 @@ def adjusted_down(adjusted_array, parent, limit)
|
|||
adjusted_array[parent] = top
|
||||
end
|
||||
|
||||
# Code for testing heapsort
|
||||
array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15].shuffle
|
||||
print heap_sort(array)
|
||||
if $0 == __FILE__
|
||||
puts 'Enter a list of numbers separated by space'
|
||||
|
||||
list = gets.split.map(&:to_i)
|
||||
p heap_sort(list)
|
||||
end
|
||||
|
|
11
sorting/heap_sort_test.rb
Normal file
11
sorting/heap_sort_test.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
require 'minitest/autorun'
|
||||
require_relative './sort_tests'
|
||||
require_relative './heap_sort'
|
||||
|
||||
class TestHeapSort < Minitest::Test
|
||||
include SortTests
|
||||
|
||||
def sort(input)
|
||||
heap_sort(input)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue