mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-25 21:58:57 +01:00
Add tests for Sorting/bogo_sort.rb
This commit is contained in:
parent
cc30012691
commit
2f53abe798
2 changed files with 21 additions and 3 deletions
|
@ -13,6 +13,8 @@ class Array
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Enter a list of numbers separated by space"
|
if $0 == __FILE__
|
||||||
str = gets.chomp.split('')
|
puts "Enter a list of numbers separated by space"
|
||||||
puts str.bogosort.join('')
|
str = gets.chomp.split('')
|
||||||
|
puts str.bogosort.join('')
|
||||||
|
end
|
||||||
|
|
16
sorting/bogo_sort_test.rb
Normal file
16
sorting/bogo_sort_test.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
require 'minitest/autorun'
|
||||||
|
require_relative './bogo_sort'
|
||||||
|
|
||||||
|
class TestBogoSort < Minitest::Test
|
||||||
|
def test_sorted_array
|
||||||
|
input = [1, 2, 3, 4, 5]
|
||||||
|
expected = input.dup
|
||||||
|
assert_equal expected, input.bogosort
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_reversed_array
|
||||||
|
input = [5, 4, 3, 2, 1]
|
||||||
|
expected = [1, 2, 3, 4, 5]
|
||||||
|
assert_equal expected, input.bogosort
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue