|
|
@ -1,4 +1,5 @@ |
|
|
|
#include "gp/utils/pair.hpp"
|
|
|
|
#include "gp/algorithms/min_max.hpp"
|
|
|
|
#include "test_scaffold.h"
|
|
|
|
|
|
|
|
#include <random>
|
|
|
@ -33,4 +34,78 @@ struct pair_test : public test_scaffold { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
append_test dummy_rsly21r43(new pair_test{}); |
|
|
|
append_test dummy_rsly21r43(new pair_test{}); |
|
|
|
|
|
|
|
template<typename T> |
|
|
|
struct sort_pair_test : public test_scaffold { |
|
|
|
uint32_t seed; |
|
|
|
|
|
|
|
sort_pair_test() { |
|
|
|
seed = std::random_device{}(); |
|
|
|
name = __FILE__ ":2_sort_pair"; |
|
|
|
name += std::to_string(seed); |
|
|
|
} |
|
|
|
|
|
|
|
virtual int run() { |
|
|
|
// TODO: Verify things, like, for real
|
|
|
|
|
|
|
|
cheap_rand setter(seed); |
|
|
|
|
|
|
|
bool result = true; |
|
|
|
std::uniform_real_distribution<T> dist{-1.0, 1.0}; |
|
|
|
for(int i = 0 ; i < 10000; i++) |
|
|
|
{ |
|
|
|
gp::pair<T, T> v{dist(setter), dist(setter)}; |
|
|
|
gp::pair<T, T> |
|
|
|
ascending{gp::min(v.first, v.second), gp::max(v.first, v.second)}, |
|
|
|
descending{gp::max(v.first, v.second), gp::min(v.first, v.second)}, |
|
|
|
clamped{gp::clamp<float>(0.25,v.first, 0.5), gp::min(0.5, v.first, v.second)}, |
|
|
|
minmaxed{gp::min<T>(dist(setter), dist(setter), dist(setter)), gp::max<T>(dist(setter), dist(setter), dist(setter))}, |
|
|
|
rngclamp{gp::clamp<T>(dist(setter),dist(setter), dist(setter)), gp::clamp<T>(dist(setter), dist(setter), dist(setter))}; |
|
|
|
result = ascending.first == descending.second ? result : false; |
|
|
|
} |
|
|
|
|
|
|
|
return !result; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
append_test dummy_5qsd5r43(new sort_pair_test<float>{}); |
|
|
|
append_test dummy_4365xv43(new sort_pair_test<double>{}); |
|
|
|
|
|
|
|
template<typename T> |
|
|
|
struct sort_pair_test2 : public test_scaffold { |
|
|
|
uint32_t seed; |
|
|
|
|
|
|
|
sort_pair_test2() { |
|
|
|
seed = std::random_device{}(); |
|
|
|
name = __FILE__ ":3_sort_pair2"; |
|
|
|
name += std::to_string(seed); |
|
|
|
} |
|
|
|
|
|
|
|
virtual int run() { |
|
|
|
// TODO: Verify things, like, for real
|
|
|
|
|
|
|
|
cheap_rand setter(seed); |
|
|
|
|
|
|
|
bool result = true; |
|
|
|
std::uniform_int_distribution<T> dist{0, 4096}; |
|
|
|
for(int i = 0 ; i < 10000; i++) |
|
|
|
{ |
|
|
|
gp::pair<T, T> v{dist(setter), dist(setter)}; |
|
|
|
gp::pair<T, T> |
|
|
|
ascending{gp::min<T>(v.first, v.second), gp::max<T>(v.first, v.second)}, |
|
|
|
descending{gp::max<T>(v.first, v.second), gp::min<T>(v.first, v.second)}, |
|
|
|
clamped{gp::clamp<T>(512,v.first, 1024), gp::min(1024, v.first, v.second)}, |
|
|
|
minmaxed{gp::min<T>(dist(setter),dist(setter), dist(setter)), gp::max<T>(dist(setter), dist(setter), dist(setter))}, |
|
|
|
rngclamp{gp::clamp<T>(dist(setter),dist(setter), dist(setter)), gp::clamp<T>(dist(setter), dist(setter), dist(setter))}; |
|
|
|
result = ascending.first == descending.second ? result : false; |
|
|
|
} |
|
|
|
|
|
|
|
return !result; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
append_test dummy_5zegfh43(new sort_pair_test2<int>{}); |
|
|
|
append_test dummy_sdghtfh4(new sort_pair_test2<unsigned long>{}); |
|
|
|
append_test dummy_judlg8gb(new sort_pair_test2<long>{}); |
|
|
|
append_test dummy_5egkzbcd(new sort_pair_test2<long long>{}); |