Created
February 13, 2017 18:37
-
-
Save diegocasmo/cca7c07152c611dde2cd376081d428cc to your computer and use it in GitHub Desktop.
Tests for an implementation of the Merge Sort algorithm in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require './merge_sort' | |
describe MergeSort do | |
before do | |
@merge_sort = MergeSort.new | |
end | |
describe "#sort" do | |
it "should sort an array of 1 element" do | |
assert_equal(@merge_sort.sort([1]), [1]) | |
end | |
it "should sort an array of multiple elements" do | |
assert_equal(@merge_sort.sort([5, 2, 7, 8, 9, 3]), [2, 3, 5, 7, 8, 9]) | |
end | |
it "should sort an array of multiple elements with equal slots" do | |
assert_equal(@merge_sort.sort([5, 5, 1, 3, 3, 7]), [1, 3, 3, 5, 5, 7]) | |
end | |
it "should sort an array of multiple elements with negative numbers" do | |
assert_equal(@merge_sort.sort([-1, -4, 2, 0, -2, 7]), [-4, -2, -1, 0, 2, 7]) | |
end | |
it "should sort an array of odd length" do | |
assert_equal(@merge_sort.sort([8, 3, 6, 2, 6, 8, 0]), [0, 2, 3, 6, 6, 8, 8]) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Merge Sort class being tested can be found here: https://gist.github.com/diegocasmo/b330010bd891c5581ee257f9aac87419