-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.cpp
36 lines (28 loc) · 809 Bytes
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <algorithm>
#include <vector>
#include <random>
#include "sorts.hpp"
int main () {
const size_t N = 1000;
std::vector<int> v(N);
std::mt19937 rng(42);
std::uniform_int_distribution<int> uniform(0, N);
for (auto& e : v)
e = uniform(rng);
std::vector<int> sorted = v;
std::sort(sorted.begin(), sorted.end());
auto map = algorithms<decltype(v)>();
auto dummy = [](int i, int j) {};
for (auto& p : map) {
std::vector<int> w = v;
std::cout << "Testing " << p.first << " sort...\t" << std::flush;
(p.second)(w.begin(), w.end(), dummy);
if (w == sorted) {
std::cout << "ok." << std::endl;
} else {
std::cout << "FAILED!" << std::endl;
}
}
return 0;
}