def test_quick_1000(): file = '../docs/1000/crescente.csv' crescente = sorting(file, method) file = '../docs/1000/decrescente.csv' decrescente = sorting(file, method) file = '../docs/1000/random.csv' random = sorting(file, method) title = method + ' 1000' plot_data(crescente, decrescente, random, title)
def test_merge_1000(): file = '../docs/1000/crescente.csv' crescente = sorting(file, method, alredy_sorted) file = '../docs/1000/decrescente.csv' decrescente = sorting(file, method, inversed) file = '../docs/1000/random.csv' random = sorting(file, method, repeated) title = method + ' 1000' plot_data(crescente, decrescente, random, title)
def test_quick(): file = '../docs/1000/crescente.csv' um = sorting(file, method) file = '../docs/1000/decrescente.csv' deum = sorting(file, method) file = '../docs/1000/random.csv' raum = sorting(file, method) file = '../docs/2000/crescente.csv' dois = sorting(file, method) file = '../docs/2000/decrescente.csv' dedois = sorting(file, method) file = '../docs/2000/random.csv' radois = sorting(file, method) names = ['1000', '2000'] crescente = [um['counter']['comparisons'], dois['counter']['comparisons']] decrescente = [ deum['counter']['comparisons'], dedois['counter']['comparisons'] ] random = [raum['counter']['comparisons'], radois['counter']['comparisons']] mocrescente = [um['counter']['movements'], dois['counter']['movements']] modecrescente = [ deum['counter']['movements'], dedois['counter']['movements'] ] morandom = [raum['counter']['movements'], radois['counter']['movements']] tecrescente = [um['total'], dois['total']] tedecrescente = [deum['total'], dedois['total']] terandom = [raum['total'], radois['total']] plt.figure(figsize=(9, 3)) plt.subplot(131) plt.ylabel('Comparações') plt.plot(names, crescente, label="crescente") plt.plot(names, decrescente, label="decrescente") plt.plot(names, random, label="random") plt.legend() plt.subplot(132) plt.ylabel('Movimentaçoes') plt.plot(names, mocrescente, label="crescente") plt.plot(names, modecrescente, label="decrescente") plt.plot(names, morandom, label="random") plt.legend() plt.subplot(133) plt.ylabel('Tempo (s)') plt.plot(names, tecrescente, label="crescente") plt.plot(names, tedecrescente, label="decrescente") plt.plot(names, terandom, label="random") plt.legend() plt.suptitle(method)
def test_normal(self): res = sorting([9, 8, 6, 5, 4]) self.assertEqual(res, [4, 5, 6, 8, 9]) self.assertEqual(sorting([3, 2, 1]), [1, 2, 3])
def test_empty(self): res = sorting([]) self.assertEqual(res, [])