def test_listsorter_QuickSortAlreadySorted(self): ls = ListSorter() in_filename = "QuickSortData.csv" out_filename = "SortedByQuickSort.csv" self.create_csvfile_random_content(in_filename, 10) self.assertEqual(StatusCode.SUCCESS, ls.set_input_data(in_filename)) self.assertEqual(StatusCode.SUCCESS, ls.execute_quick_sort()) self.assertEqual(StatusCode.SUCCESS, ls.set_output_data(out_filename)) self.assertEqual(StatusCode.LIST_ALREADY_SORTED, ls.execute_quick_sort()) self.delete_file(in_filename) self.delete_file(out_filename)
def test_listsorter_QuickSortVSHeapSort(self): QuickSort = ListSorter() HeapSort = ListSorter() in_filename = "InputData.csv" self.create_csvfile_random_content(in_filename, 5000) # Read Input File to respective Sort self.assertEqual(StatusCode.SUCCESS, QuickSort.set_input_data(in_filename)) self.assertEqual(StatusCode.SUCCESS, HeapSort.set_input_data(in_filename)) #Execute Sorts QuickSort.execute_merge_sort() HeapSort.execute_quick_sort() #Compare Lists self.assertListEqual(QuickSort.working_list, HeapSort.working_list) self.delete_file(in_filename)
def test_listsorter_QuickSortEmptyList(self): ls = ListSorter() self.assertEqual(StatusCode.LIST_IS_EMPTY, ls.execute_quick_sort())