diff --git a/bigO/BigO.py b/bigO/BigO.py index 3d928c88dc4fbcc7662e6108b486b05a8d324a17..34104ea60c44a12f95ecf29663177c5bfbaad030 100644 --- a/bigO/BigO.py +++ b/bigO/BigO.py @@ -469,7 +469,7 @@ class BigO: print(f"Running {function.__name__}(tests)") for test in result: - cplx, _ = self.test(function, test, prtResult=False) + cplx = self.test(function, test, prtResult=False) result[test] = cplx cplxInt = self._complexity2int(cplx) diff --git a/bigO/__init__.py b/bigO/__init__.py index 9cc54de322c9b4280984abdea92e88d41a7dc005..9987b35c9bacfa2bead4c237520a6f2d564947db 100644 --- a/bigO/__init__.py +++ b/bigO/__init__.py @@ -6,4 +6,4 @@ __all__ = [ "utils", ] -__version__ = "0.0.9.8.3" +__version__ = "0.0.9.8.4" diff --git a/bigO/version.py b/bigO/version.py index cda5df0e39eba05d3d65a6ebed3e8af077d32c38..2db6e223ecbb4d5ae3704402d9f41a91dd239bab 100644 --- a/bigO/version.py +++ b/bigO/version.py @@ -1 +1 @@ -__version__ = "0.0.9.8.3" +__version__ = "0.0.9.8.4" diff --git a/tests/test_array.py b/tests/test_array.py index 5ecf35d6f1229eb52a2566435eed3784820c1778..432eb88f89c8b401605908034373ee75c84a40c5 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -1,42 +1,47 @@ -from bigO import BigO +import pytest -def test_gen(): - gen = BigO() - print(gen.genRandomArray(20)) - print(gen.genRandomString(5, 20)) - print(gen.genSortedArray(20)) - print(gen.genReversedArray(20)) - print(gen.genPartialArray(20)) - print(gen.genKsortedArray(20, 6)) +@pytest.fixture +def BigO(): + from bigO import BigO + + lib = BigO() + return lib + + +def test_BigO(BigO): + print(BigO.genRandomArray(20)) + print(BigO.genRandomString(5, 20)) + print(BigO.genSortedArray(20)) + print(BigO.genReversedArray(20)) + print(BigO.genPartialArray(20)) + print(BigO.genKsortedArray(20, 6)) for i in range(21): - arr = gen.genKsortedArray(20, i) + arr = BigO.genKsortedArray(20, i) assert isKSortedArray(arr, i) == True - print(gen.genAlmostEqualArray(9)) - print(gen.genAlmostEqualArray(20)) - print(gen.genEqualArray(20)) - print(gen.genHoleArray(20)) - print(gen.genRandomBigArray(20)) - + print(BigO.genAlmostEqualArray(9)) + print(BigO.genAlmostEqualArray(20)) + print(BigO.genEqualArray(20)) + print(BigO.genHoleArray(20)) + print(BigO.genRandomBigArray(20)) -def test_Ksorted(): - gen = BigO() - arr = gen.genKsortedArray(9, 1) +def test_Ksorted(BigO): + arr = BigO.genKsortedArray(9, 1) assert isKSortedArray(arr, 1) == True - arr = gen.genKsortedArray(100, 9) + arr = BigO.genKsortedArray(100, 9) assert isKSortedArray(arr, 9) == True - arr = gen.genKsortedArray(9, 9) + arr = BigO.genKsortedArray(9, 9) assert isKSortedArray(arr, 9) == True - arr = gen.genKsortedArray(10, 5) + arr = BigO.genKsortedArray(10, 5) assert isKSortedArray(arr, 5) == True - arr = gen.genKsortedArray(1000, 100) + arr = BigO.genKsortedArray(1000, 100) assert isKSortedArray(arr, 100) == True diff --git a/tests/test_bigO.py b/tests/test_bigO.py index 62069bd02c204018a91ea60dce0d9c1cf45745d0..eb37f69385f0c935b42b326092518bf00714fae4 100644 --- a/tests/test_bigO.py +++ b/tests/test_bigO.py @@ -1,22 +1,27 @@ -from bigO import BigO +import pytest -def test_cplx(): +@pytest.fixture +def BigO(): + from bigO import BigO + lib = BigO() - assert lib._complexity2str(0) == "f(n)" - assert lib._complexity2str(2) == "O(n)" - assert lib._complexity2str(5) == "O(n^2)" + return lib -def test_fitting(): - lib = BigO() - assert lib._fittingCurve(1)(100) == 1.0 - assert lib._fittingCurve(5)(2) == 4 # O(n^2) - assert lib._fittingCurve(6)(2) == 8 # O(n^3) +def test_cplx(BigO): + assert BigO._complexity2str(0) == "f(n)" + assert BigO._complexity2str(2) == "O(n)" + assert BigO._complexity2str(5) == "O(n^2)" -def test_estimate(): - lib = BigO() +def test_fitting(BigO): + assert BigO._fittingCurve(1)(100) == 1.0 + assert BigO._fittingCurve(5)(2) == 4 # O(n^2) + assert BigO._fittingCurve(6)(2) == 8 # O(n^3) + + +def test_estimate(BigO): n = [10, 100, 1000, 10000] times = [ 3.959999999736397e-06, @@ -24,5 +29,5 @@ def test_estimate(): 0.015288159999999884, 1.62602698, ] - result = lib._estimate(n, times) + result = BigO._estimate(n, times) assert result._to_str() == "O(n^2)", "Estimation is wrong." diff --git a/tests/test_compare.py b/tests/test_compare.py index 6a656ede09a5c959fe472a42f9be1771e10c4e05..ee39f185b4f8593e61c09e46f6a6d19072be617c 100644 --- a/tests/test_compare.py +++ b/tests/test_compare.py @@ -1,102 +1,103 @@ -from bigO import BigO +import pytest from bigO import algorithm -def test_run(): +@pytest.fixture +def BigO(): + from bigO import BigO + lib = BigO() + return lib + - result = lib.compare(algorithm.bubbleSort, algorithm.insertSort, "reversed", 5000) - result = lib.compare( +def test_run(BigO): + result = BigO.compare(algorithm.bubbleSort, algorithm.insertSort, "reversed", 5000) + result = BigO.compare( algorithm.insertSort, algorithm.insertSortOptimized, "reversed", 5000 ) - result = lib.compare( + result = BigO.compare( algorithm.quickSort, algorithm.quickSortHoare, "reversed", 50000 ) - result = lib.compare(algorithm.timSort, algorithm.introSort, "reversed", 50000) - result = lib.compare(sorted, algorithm.introSort, "reversed", 50000) + result = BigO.compare(algorithm.timSort, algorithm.introSort, "reversed", 50000) + result = BigO.compare(sorted, algorithm.introSort, "reversed", 50000) - result = lib.compare(algorithm.heapSort, algorithm.heapSort2, "all", 50000) - result = lib.compare(algorithm.introSort, algorithm.quickSortHeap, "all", 50000) + result = BigO.compare(algorithm.heapSort, algorithm.heapSort2, "all", 50000) + result = BigO.compare(algorithm.introSort, algorithm.quickSortHeap, "all", 50000) -def test_quickcomp(): - lib = BigO() - +def test_quickcomp(BigO): # Hoare + Tail recur should be faster than random pivot choosing recursive one - result = lib.compare(algorithm.quickSort, algorithm.quickSortHoare, "random", 50000) - result = lib.compare( + result = BigO.compare( + algorithm.quickSort, algorithm.quickSortHoare, "random", 50000 + ) + result = BigO.compare( algorithm.quickSortHoare, algorithm.quickSortHeap, "random", 50000 ) - result = lib.compare( + result = BigO.compare( algorithm.quickSort, algorithm.quickSortHoare, "reversed", 50000 ) - result = lib.compare( + result = BigO.compare( algorithm.quickSortHoare, algorithm.quickSortHeap, "reversed", 50000 ) - result = lib.compare(algorithm.quickSort, algorithm.quickSortHoare, "sorted", 50000) - result = lib.compare( + result = BigO.compare( + algorithm.quickSort, algorithm.quickSortHoare, "sorted", 50000 + ) + result = BigO.compare( algorithm.quickSortHoare, algorithm.quickSortHeap, "sorted", 50000 ) - result = lib.compare( + result = BigO.compare( algorithm.quickSort, algorithm.quickSortHoare, "partial", 50000 ) - result = lib.compare( + result = BigO.compare( algorithm.quickSortHoare, algorithm.quickSortHeap, "partial", 50000 ) - result = lib.compare( + result = BigO.compare( algorithm.quickSort, algorithm.quickSortHoare, "Ksorted", 50000 ) - result = lib.compare( + result = BigO.compare( algorithm.quickSortHoare, algorithm.quickSortHeap, "Ksorted", 50000 ) print(result) -def test_go(): - lib = BigO() +def test_go(BigO): + BigO.compare(algorithm.goSort, algorithm.introSort, "random", 100000) + BigO.compare(algorithm.goSort, algorithm.quickSortHoare, "random", 10000) - lib.compare(algorithm.goSort, algorithm.introSort, "random", 100000) - lib.compare(algorithm.goSort, algorithm.quickSortHoare, "random", 10000) + BigO.compare(algorithm.goSort, algorithm.heapSort, "random", 10000) + BigO.compare(algorithm.goSort, algorithm.timSort, "random", 10000) - lib.compare(algorithm.goSort, algorithm.heapSort, "random", 10000) - lib.compare(algorithm.goSort, algorithm.timSort, "random", 10000) + BigO.compare(algorithm.goSort, algorithm.quickSortHoare, "Ksorted", 10000) + BigO.compare(algorithm.goSort, algorithm.quickSortHoare, "Ksorted", 10000) - lib.compare(algorithm.goSort, algorithm.quickSortHoare, "Ksorted", 10000) - lib.compare(algorithm.goSort, algorithm.quickSortHoare, "Ksorted", 10000) +def test_mini(BigO): + BigO.compare(algorithm.insertSortOptimized, algorithm.insertSort, "random", 16) -def test_mini(): - lib = BigO() - - lib.compare(algorithm.insertSortOptimized, algorithm.insertSort, "random", 16) - - lib.compare(algorithm.bubbleSort, algorithm.insertSort, "random", 16) - lib.compare(algorithm.insertSort, algorithm.selectionSort, "random", 16) - lib.compare(algorithm.bubbleSort, algorithm.selectionSort, "random", 16) + BigO.compare(algorithm.bubbleSort, algorithm.insertSort, "random", 16) + BigO.compare(algorithm.insertSort, algorithm.selectionSort, "random", 16) + BigO.compare(algorithm.bubbleSort, algorithm.selectionSort, "random", 16) - lib.compare(algorithm.bubbleSort, algorithm.insertSort, "reversed", 16) - lib.compare(algorithm.insertSort, algorithm.selectionSort, "reversed", 16) - lib.compare(algorithm.bubbleSort, algorithm.selectionSort, "reversed", 16) + BigO.compare(algorithm.bubbleSort, algorithm.insertSort, "reversed", 16) + BigO.compare(algorithm.insertSort, algorithm.selectionSort, "reversed", 16) + BigO.compare(algorithm.bubbleSort, algorithm.selectionSort, "reversed", 16) -def test_all(): - lib = BigO() - result = lib.compare( +def test_all(BigO): + result = BigO.compare( algorithm.quickSortHoare, algorithm.quickSortHeap, "all", 50000 ) - result = lib.compare(algorithm.insertSort, algorithm.bubbleSort, "all", 5000) + result = BigO.compare(algorithm.insertSort, algorithm.bubbleSort, "all", 5000) print(result) - result = lib.compare(algorithm.quickSortHoare, algorithm.insertSort, "all", 5000) - + result = BigO.compare(algorithm.quickSortHoare, algorithm.insertSort, "all", 5000) -def test_custom(): - lib = BigO() - lib.compare(algorithm.doubleSelectionSort, algorithm.selectionSort, "all", 5000) +def test_custom(BigO): + BigO.compare(algorithm.doubleSelectionSort, algorithm.selectionSort, "all", 5000) diff --git a/tests/test_runtime.py b/tests/test_runtime.py index 6cbb727857c607bd1b018f38a7607eae7ae6652b..1d95f028d4dc2685ceec2f5be8483b8667aeac45 100644 --- a/tests/test_runtime.py +++ b/tests/test_runtime.py @@ -1,22 +1,28 @@ -from bigO import BigO +import pytest from bigO import algorithm -def test_run(): +@pytest.fixture +def BigO(): + from bigO import BigO + lib = BigO() + return lib + - lib.runtime(sorted, "random", 5000) - lib.runtime(algorithm.bubbleSort, "random", 5000) - lib.runtime(algorithm.countSort, "random", 5000) - lib.runtime(algorithm.binaryInsertSort, "random", 5000) - lib.runtime(algorithm.gnomeSort, "random", 5000) - lib.runtime(algorithm.heapSort, "random", 5000) - lib.runtime(algorithm.insertSort, "random", 5000) - lib.runtime(algorithm.insertSortOptimized, "random", 5000) - lib.runtime(algorithm.introSort, "random", 5000) - lib.runtime(algorithm.mergeSort, "random", 5000) - lib.runtime(algorithm.timSort, "random", 5000) - lib.runtime(algorithm.selectionSort, "random", 5000) +def test_run(BigO): + BigO.runtime(sorted, "random", 5000) + BigO.runtime(algorithm.bubbleSort, "random", 5000) + BigO.runtime(algorithm.countSort, "random", 5000) + BigO.runtime(algorithm.binaryInsertSort, "random", 5000) + BigO.runtime(algorithm.gnomeSort, "random", 5000) + BigO.runtime(algorithm.heapSort, "random", 5000) + BigO.runtime(algorithm.insertSort, "random", 5000) + BigO.runtime(algorithm.insertSortOptimized, "random", 5000) + BigO.runtime(algorithm.introSort, "random", 5000) + BigO.runtime(algorithm.mergeSort, "random", 5000) + BigO.runtime(algorithm.timSort, "random", 5000) + BigO.runtime(algorithm.selectionSort, "random", 5000) def brokenBubble(array): @@ -35,41 +41,34 @@ def brokenBubble(array): return array -def test_custom(): - lib = BigO() - +def test_custom(BigO): arr = ["dbc", "bbc", "ccd", "ef", "az"] - time, result = lib.runtime(brokenBubble, arr) + time, result = BigO.runtime(brokenBubble, arr) print(time) print(result) -def test_str_array(): - lib = BigO() - - time, result = lib.runtime(algorithm.bubbleSort, "string", 10) +def test_str_array(BigO): + time, result = BigO.runtime(algorithm.bubbleSort, "string", 10) print(result) - time, result = lib.runtime(algorithm.introSort, "string", 10) + time, result = BigO.runtime(algorithm.introSort, "string", 10) print(result) - time, result = lib.runtime(algorithm.quickSort, "string", 10) + time, result = BigO.runtime(algorithm.quickSort, "string", 10) print(result) -def test_big(): - lib = BigO() - lib.runtime(algorithm.bubbleSort, "random", 5000) - lib.runtime(algorithm.bubbleSort, "big", 5000) +def test_big(BigO): + BigO.runtime(algorithm.bubbleSort, "random", 5000) + BigO.runtime(algorithm.bubbleSort, "big", 5000) -def test_epoch(): - lib = BigO() - lib.runtime(algorithm.quickSort, "random", 5000, 3, True) - lib.runtime(algorithm.quickSortHoare, "random", 5000, 3, True) +def test_epoch(BigO): + BigO.runtime(algorithm.quickSort, "random", 5000, 3, True) + BigO.runtime(algorithm.quickSortHoare, "random", 5000, 3, True) -def test_heap(): - lib = BigO() - lib.runtime(algorithm.heapSort2, "random", 500) +def test_heap(BigO): + BigO.runtime(algorithm.heapSort2, "random", 500) diff --git a/tests/test_sort.py b/tests/test_sort.py index 8b8bbef9d989406440ab61fa08eb87242cff5d7a..728ea04afe716838df311922479ce8532c25d91d 100644 --- a/tests/test_sort.py +++ b/tests/test_sort.py @@ -1,6 +1,13 @@ -from bigO import algorithm -from bigO import BigO import pytest +from bigO import algorithm + + +@pytest.fixture +def BigO(): + from bigO import BigO + + lib = BigO() + return lib def empty(array): @@ -23,9 +30,7 @@ def brokenBubble(array): return array -def test_none(): - tester = BigO() - +def test_none(BigO): def countSort(arr): # stable # Time Complexity : O(n) | Space Complexity : O(n) minValue = min(arr) @@ -43,164 +48,139 @@ def test_none(): index += 1 buckets[i] -= 1 - _, _ = tester.test(countSort, "random") # will return a warning - + _, _ = BigO.test(countSort, "random") # will return a warning -def test_Ksorted(): - tester = BigO() +def test_Ksorted(BigO): # Results may vary, O(n) possible - complexity = tester.test(algorithm.introSort, "Ksorted") - complexity = tester.test(algorithm.quickSort, "Ksorted") - complexity = tester.test(algorithm.timSort, "Ksorted") - complexity = tester.test(algorithm.countSort, "Ksorted") + complexity = BigO.test(algorithm.introSort, "Ksorted") + complexity = BigO.test(algorithm.quickSort, "Ksorted") + complexity = BigO.test(algorithm.timSort, "Ksorted") + complexity = BigO.test(algorithm.countSort, "Ksorted") -def test_empty(): - big = BigO() +def test_empty(BigO): cplx = big.test(empty, "random") @pytest.mark.timeout(600) -def test_bubble(): - tester = BigO() - - complexity = tester.test(algorithm.bubbleSort, "random") - # complexity = tester.test(algorithm.bubbleSort, "sorted") - # complexity = tester.test(algorithm.bubbleSort, "reversed") - # complexity = tester.test(algorithm.bubbleSort, "partial") - # complexity = tester.test(algorithm.bubbleSort, "Ksorted") - # complexity = tester.test(algorithm.bubbleSort, "almost_equal") - # complexity = tester.test(algorithm.bubbleSort, "equal") - # complexity = tester.test(algorithm.bubbleSort, "hole") - - -def test_brokenBubble(): - tester = BigO() - _ = tester.test(brokenBubble, "random") +def test_bubble(BigO): + complexity = BigO.test(algorithm.bubbleSort, "random") + complexity = BigO.test(algorithm.bubbleSort, "sorted") + complexity = BigO.test(algorithm.bubbleSort, "reversed") + complexity = BigO.test(algorithm.bubbleSort, "partial") + complexity = BigO.test(algorithm.bubbleSort, "Ksorted") + complexity = BigO.test(algorithm.bubbleSort, "almost_equal") + complexity = BigO.test(algorithm.bubbleSort, "equal") + complexity = BigO.test(algorithm.bubbleSort, "hole") + + +def test_brokenBubble(BigO): + _ = BigO.test(brokenBubble, "random") # will assert at index 0 -def test_count(): - tester = BigO() - +def test_count(BigO): # Results may vary - complexity = tester.test(algorithm.countSort, "random") + complexity = BigO.test(algorithm.countSort, "random") assert complexity == "O(n)" - complexity = tester.test(algorithm.countSort, "sorted") + complexity = BigO.test(algorithm.countSort, "sorted") assert complexity == "O(n)" - complexity = tester.test(algorithm.countSort, "reversed") + complexity = BigO.test(algorithm.countSort, "reversed") assert complexity == "O(n)" - complexity = tester.test(algorithm.countSort, "partial") + complexity = BigO.test(algorithm.countSort, "partial") assert complexity == "O(n)" - complexity = tester.test(algorithm.countSort, "Ksorted") + complexity = BigO.test(algorithm.countSort, "Ksorted") assert complexity == "O(n)" @pytest.mark.timeout(600) -def test_insertion(): - tester = BigO() - - complexity = tester.test(algorithm.insertSort, "random") - complexity = tester.test(algorithm.insertSort, "sorted") - complexity = tester.test(algorithm.insertSort, "reversed") - complexity = tester.test(algorithm.insertSort, "partial") - complexity = tester.test(algorithm.insertSort, "Ksorted") - complexity = tester.test(algorithm.insertSort, "string") +def test_insertion(BigO): + complexity = BigO.test(algorithm.insertSort, "random") + complexity = BigO.test(algorithm.insertSort, "sorted") + complexity = BigO.test(algorithm.insertSort, "reversed") + complexity = BigO.test(algorithm.insertSort, "partial") + complexity = BigO.test(algorithm.insertSort, "Ksorted") + complexity = BigO.test(algorithm.insertSort, "string") -def test_intro(): - tester = BigO() - +def test_intro(BigO): # Results may vary, O(n) possible - complexity = tester.test(algorithm.introSort, "random") - complexity = tester.test(algorithm.introSort, "sorted") - complexity = tester.test(algorithm.introSort, "reversed") - complexity = tester.test(algorithm.introSort, "partial") - complexity = tester.test(algorithm.introSort, "Ksorted") + complexity = BigO.test(algorithm.introSort, "random") + complexity = BigO.test(algorithm.introSort, "sorted") + complexity = BigO.test(algorithm.introSort, "reversed") + complexity = BigO.test(algorithm.introSort, "partial") + complexity = BigO.test(algorithm.introSort, "Ksorted") # median of three won't work on string array @pytest.mark.timeout(600) -def test_selection(): - tester = BigO() - - tester.test(algorithm.selectionSort, "random") - tester.test(algorithm.selectionSort, "reversed") - tester.test(algorithm.selectionSort, "sorted") - tester.test(algorithm.selectionSort, "partial") - tester.test(algorithm.selectionSort, "Ksorted") - tester.test(algorithm.selectionSort, "string") +def test_selection(BigO): + BigO.test(algorithm.selectionSort, "random") + BigO.test(algorithm.selectionSort, "reversed") + BigO.test(algorithm.selectionSort, "sorted") + BigO.test(algorithm.selectionSort, "partial") + BigO.test(algorithm.selectionSort, "Ksorted") + BigO.test(algorithm.selectionSort, "string") -def test_timsort(): - tester = BigO() - +def test_timsort(BigO): # Results may vary - complexity = tester.test(algorithm.timSort, "random") - complexity = tester.test(algorithm.timSort, "sorted") - complexity = tester.test(algorithm.timSort, "reversed") - complexity = tester.test(algorithm.timSort, "partial") - complexity = tester.test(algorithm.timSort, "Ksorted") - complexity = tester.test(algorithm.timSort, "hole") - - -def test_heap(): - tester = BigO() - complexity = tester.test(algorithm.heapSort2, "random") - complexity = tester.test(algorithm.heapSort2, "sorted") - complexity = tester.test(algorithm.heapSort2, "reversed") - complexity = tester.test(algorithm.heapSort2, "partial") - complexity = tester.test(algorithm.heapSort2, "Ksorted") - - -def test_quickSort(): - tester = BigO() - - complexity = tester.test(algorithm.quickSort, "random") - complexity = tester.test(algorithm.quickSort, "sorted") - complexity = tester.test(algorithm.quickSort, "reversed") - complexity = tester.test(algorithm.quickSort, "partial") - complexity = tester.test(algorithm.quickSort, "Ksorted") - complexity = tester.test(algorithm.quickSort, "string") - - -def test_quickSort(): - tester = BigO() - - complexity = tester.test(algorithm.quickSortHoare, "random") - complexity = tester.test(algorithm.quickSortHoare, "sorted") - complexity = tester.test(algorithm.quickSortHoare, "reversed") - complexity = tester.test(algorithm.quickSortHoare, "partial") - complexity = tester.test(algorithm.quickSortHoare, "Ksorted") - complexity = tester.test(algorithm.quickSortHoare, "hole") - complexity = tester.test(algorithm.quickSortHoare, "equal") - complexity = tester.test(algorithm.quickSortHoare, "almost_equal") - complexity = tester.test(algorithm.quickSortHoare, "string") - - -def test_sort(): - lib = BigO() - - lib.test(sorted, "random") - lib.test(sorted, "sorted") - lib.test(sorted, "reversed") - lib.test(sorted, "partial") - lib.test(sorted, "Ksorted") - lib.test(sorted, "string") - lib.test(sorted, "hole") - lib.test(sorted, "euqal") - lib.test(sorted, "almost_equal") - - -def test_all_cases(): - lib = BigO() - - lib.test_all(sorted) - lib.test_all(algorithm.bubbleSort) - lib.test_all(algorithm.insertSort) - lib.test_all(algorithm.selectionSort) - lib.test_all(algorithm.doubleSelectionSort) - lib.test_all(algorithm.timSort) - lib.test_all(algorithm.heapSort2) - lib.test_all(algorithm.quickSort) + complexity = BigO.test(algorithm.timSort, "random") + complexity = BigO.test(algorithm.timSort, "sorted") + complexity = BigO.test(algorithm.timSort, "reversed") + complexity = BigO.test(algorithm.timSort, "partial") + complexity = BigO.test(algorithm.timSort, "Ksorted") + complexity = BigO.test(algorithm.timSort, "hole") + + +def test_heap(BigO): + complexity = BigO.test(algorithm.heapSort2, "random") + complexity = BigO.test(algorithm.heapSort2, "sorted") + complexity = BigO.test(algorithm.heapSort2, "reversed") + complexity = BigO.test(algorithm.heapSort2, "partial") + complexity = BigO.test(algorithm.heapSort2, "Ksorted") + + +def test_quickSort(BigO): + complexity = BigO.test(algorithm.quickSort, "random") + complexity = BigO.test(algorithm.quickSort, "sorted") + complexity = BigO.test(algorithm.quickSort, "reversed") + complexity = BigO.test(algorithm.quickSort, "partial") + complexity = BigO.test(algorithm.quickSort, "Ksorted") + complexity = BigO.test(algorithm.quickSort, "string") + + +def test_quickSort(BigO): + complexity = BigO.test(algorithm.quickSortHoare, "random") + complexity = BigO.test(algorithm.quickSortHoare, "sorted") + complexity = BigO.test(algorithm.quickSortHoare, "reversed") + complexity = BigO.test(algorithm.quickSortHoare, "partial") + complexity = BigO.test(algorithm.quickSortHoare, "Ksorted") + complexity = BigO.test(algorithm.quickSortHoare, "hole") + complexity = BigO.test(algorithm.quickSortHoare, "equal") + complexity = BigO.test(algorithm.quickSortHoare, "almost_equal") + complexity = BigO.test(algorithm.quickSortHoare, "string") + + +def test_sort(BigO): + BigO.test(sorted, "random") + BigO.test(sorted, "sorted") + BigO.test(sorted, "reversed") + BigO.test(sorted, "partial") + BigO.test(sorted, "Ksorted") + BigO.test(sorted, "string") + BigO.test(sorted, "hole") + BigO.test(sorted, "euqal") + BigO.test(sorted, "almost_equal") + + +def test_all_cases(BigO): + BigO.test_all(sorted) + # BigO.test_all(algorithm.bubbleSort) + # BigO.test_all(algorithm.insertSort) + # BigO.test_all(algorithm.selectionSort) + # BigO.test_all(algorithm.doubleSelectionSort) + # BigO.test_all(algorithm.timSort) + # BigO.test_all(algorithm.heapSort2) + # BigO.test_all(algorithm.quickSort)