Added tests for comb_sort.cpp

This commit is contained in:
Ayaan Khan
2020-06-24 01:49:33 +05:30
parent f030a69288
commit 92d2bf012a

View File

@@ -17,6 +17,7 @@
#include <algorithm>
#include <iostream>
#include <cassert>
/**
*
@@ -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];