diff --git a/sorting/comb_sort.cpp b/sorting/comb_sort.cpp index 7e62c04ff..00b12fcb2 100644 --- a/sorting/comb_sort.cpp +++ b/sorting/comb_sort.cpp @@ -17,6 +17,7 @@ #include #include +#include /** * @@ -69,8 +70,26 @@ void CombSort(int *arr, int l, int r) { } } +void tests() { + /// Test 1 + int arr1[10] = {34, 56, 6, 23, 76, 34, 76, 343, 4, 76}; + CombSort(arr1, 0, 10); + assert(std::is_sorted(arr1, arr1 + 10)); + std::cout << "Test 1 passed\n"; + + /// Test 2 + int arr2[8] = {-6, 56, -45, 56, 0, -1, 8, 8}; + CombSort(arr2, 0, 8); + assert(std::is_sorted(arr2, arr2 + 8)); + std::cout << "Test 2 Passed\n"; +} + /** Main function */ int main() { + /// Running predefined tests + tests(); + + /// For user interaction int n; std::cin >> n; int *arr = new int[n];