class TestMergeSort(unittest.TestCase):
    @classmethod
    def setUpClass(self):

        self.items = [38, 27, 43, 3, 9, 82, 10]
        self.sort = MergeSort()

    def test_merge_sort(self):
        print '---- depth first search ----'
        print self.sort.merge_sort(self.items)
class TestMergeSort(unittest.TestCase):

    @classmethod
    def setUpClass(self):

        self.items = [38, 27, 43, 3, 9, 82, 10]
        self.sort = MergeSort()

        
    def test_merge_sort(self):
        print '---- depth first search ----'
        print self.sort.merge_sort(self.items)
Beispiel #3
0
    def test_empty(self):
        input = []

        expected = []
        actual = MergeSort().sort(input)

        self.assertEqual(expected, actual)
Beispiel #4
0
    def test_unsorted_values_with_duplicates(self):
        input = [3, 1, 2, 2]

        expected = [1, 2, 2, 3]
        actual = MergeSort().sort(input)

        self.assertEqual(expected, actual)
Beispiel #5
0
    def test_single_value(self):
        input = [1]

        expected = [1]
        actual = MergeSort().sort(input)

        self.assertEqual(expected, actual)
Beispiel #6
0
 def test_mergesort(self):
     self.is_ordenado(MergeSort(self.ordenado, 'MergeSort Ordenado'))
     self.is_ordenado(MergeSort(self.reverso, 'MergeSort Reverso'))
     self.is_ordenado(MergeSort(self.aleatorio1, 'MergeSort Aleatorio1'))
     self.is_ordenado(MergeSort(self.aleatorio2, 'MergeSort Aleatorio2'))
     self.is_ordenado(MergeSort(self.aleatorio3, 'MergeSort Aleatorio3'))
     self.is_ordenado(MergeSort(self.aleatorio4, 'MergeSort Aleatorio4'))
Beispiel #7
0
 def test_sorted_array(self):
     arr = [-8, -5, 1, 2, 2, 3, 8, 10]
     result = MergeSort().sort(arr)
     self.assertEqual(result, [-8, -5, 1, 2, 2, 3, 8, 10])
Beispiel #8
0
 def test_random_array(self):
     arr = [8, 1, -5, 3, 2, 2, -8, 10]
     result = MergeSort().sort(arr)
     self.assertEqual(result, [-8, -5, 1, 2, 2, 3, 8, 10])
Beispiel #9
0
 def test_reverse_sorted_array(self):
     arr = [5, 3, 1, -4, -6]
     result = MergeSort().sort(arr)
     self.assertEqual([-6, -4, 1, 3, 5], result)
Beispiel #10
0
 def test_empty_Array(self):
     arr = []
     result = MergeSort().sort(arr)
     self.assertEqual([], result)
Beispiel #11
0
 def test_array_all_same(self):
     arr = [1, 1, 1]
     result = MergeSort().sort(arr)
     self.assertEqual([1, 1, 1], result)
    def test_mergesort(self):
        self.assertEqual(MergeSort()(L1), L1s)

        for i in range(1):
            self.assertEqual(MergeSort()(L2), L2s)
 def test_mergesort_class_singleton(self):
     a = MergeSort()
     b = MergeSort()
     self.assertEqual(id(a), id(b))
    def setUpClass(self):

        self.items = [38, 27, 43, 3, 9, 82, 10]
        self.sort = MergeSort()
    def setUpClass(self):

        self.items = [38, 27, 43, 3, 9, 82, 10]
        self.sort = MergeSort()
Beispiel #16
0
from mergesort import MergeSort
import random


def ArrayFactory(n):
    l = random.sample(range(0, n * 2), n)
    return l


def SortCheck(A, B):
    for i in range(len(A)):
        if A[i] != B[i]:
            break

    if i == len(A) - 1:
        return "Niz je dobro slozen"
    else:
        return "Niz nije dobro slozen"


if __name__ == "__main__":
    A = ArrayFactory(40)
    B = A[:]
    print("Niz: ", A)
    MergeSort(A, 0, len(A) - 1)
    print("Slozen: ", A)

    #Test
    B.sort(reverse=True)
    print("Test: ", SortCheck(A, B))
Beispiel #17
0
from mergesort import MergeSort
from quicksort import QuickSort
from insertionsort import InsertionSort
from bubblesort import BubbleSort

MergeSort = MergeSort()
QuickSort = QuickSort()
InsertionSort = InsertionSort()
BubbleSort = BubbleSort()