import random from algorithms import merge_sort NUM_ELEMENTS = 100 MAX_INT = 100 unsorted = [random.randint(0, MAX_INT) for i in xrange(NUM_ELEMENTS)] sorted = merge_sort.sort(unsorted) for i in xrange(NUM_ELEMENTS - 1): if sorted[i] > sorted[i + 1]: print "ERROR" exit(1) print "SUCCESS" print sorted exit(0)
def test_sort(self): result = merge_sort.sort(self.list) self.assertTrue(result == self.expected)
def test_sort(self): A = [5, 2, 4, 6, 1, 3] res = merge_sort.sort(A) self.assertEqual(res, [1, 2, 3, 4, 5, 6])
def test_sort(self): test = data.random_ints(100) merge_sort.sort(test) self.assertTrue(assertions.is_sorted(test))