mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-11 06:26:05 +08:00
Added tests for comb_sort.cpp
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user