mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-11-16 19:50:00 +01:00
Add tests for quicksort
This commit is contained in:
parent
c14e58f068
commit
3b9fb45c73
2 changed files with 17 additions and 2 deletions
|
@ -11,5 +11,9 @@ def quicksort(arr)
|
|||
[*quicksort(left), pivot, *quicksort(right)]
|
||||
end
|
||||
|
||||
arr = [34, 2, 1, 5, 3]
|
||||
p quicksort(arr)
|
||||
if $0 == __FILE__
|
||||
puts 'Enter a list of numbers separated by space'
|
||||
|
||||
list = gets.split.map(&:to_i)
|
||||
p quicksort(list)
|
||||
end
|
||||
|
|
11
sorting/quicksort_test.rb
Normal file
11
sorting/quicksort_test.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
require 'minitest/autorun'
|
||||
require_relative './sort_tests'
|
||||
require_relative './quicksort'
|
||||
|
||||
class TestQuicksort < Minitest::Test
|
||||
include SortTests
|
||||
|
||||
def sort(input)
|
||||
quicksort(input)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue