Created
July 11, 2013 20:07
-
-
Save chbatey/5978758 to your computer and use it in GitHub Desktop.
mergesort_test
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
import unittest | |
from mergesort import MergeSort | |
class MergeSortTest(unittest.TestCase): | |
def setUp(self): | |
self.under_test = MergeSort() | |
def test_empty_array(self): | |
array_to_sort = [] | |
sorted_array = MergeSort.sort(array_to_sort) | |
self.assertEqual([], array_to_sort) | |
def test_single_element(self): | |
array_to_sort = [1] | |
sorted_array = MergeSort.sort(array_to_sort) | |
self.assertEqual([1], sorted_array) | |
def test_two_elements_sorted(self): | |
array_to_sort = [1, 2] | |
sorted_array = MergeSort.sort(array_to_sort) | |
self.assertEqual([1, 2], sorted_array) | |
def test_two_elements_not_sorted(self): | |
array_to_sort = [2, 1] | |
sorted_array = MergeSort.sort(array_to_sort) | |
self.assertEqual([1, 2], sorted_array) | |
def test_three_elements_not_sorted(self): | |
array_to_sort = [2, 1, 3] | |
sorted_array = MergeSort.sort(array_to_sort) | |
self.assertEqual([1, 2, 3], sorted_array) | |
def test_three_elements_sorted(self): | |
array_to_sort = [1,2,3] | |
sorted_array = MergeSort.sort(array_to_sort) | |
self.assertEqual([1, 2, 3], sorted_array) | |
def test_many_elements(self): | |
array_to_sort = [2, 1, 70, 8, 4, 45, 7, 7] | |
sorted_array = MergeSort.sort(array_to_sort) | |
self.assertEqual([1, 2, 4, 7, 7, 8, 45, 70], sorted_array) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment