40 lines
745 B
C++
40 lines
745 B
C++
#include <fuc2/testing.hpp>
|
|
#include "algos/stats.hpp"
|
|
#include "algos/rand.hpp"
|
|
#include <cmath>
|
|
#include <fmt/core.h>
|
|
|
|
using namespace fuc2;
|
|
|
|
namespace stats_tests {
|
|
|
|
void test_basic_stats_tests() {
|
|
Stats stat1;
|
|
stat1.sample(1.0);
|
|
|
|
for(int i = 0; i < 20; i++) {
|
|
double x = Random::normal(20.0,5.0);
|
|
stat1.sample(x);
|
|
CHECK(!std::isnan(stat1.stddev()));
|
|
CHECK(stat1.mean() < stat1.mean() + stat1.stddev() * 4.0);
|
|
}
|
|
|
|
stat1.dump();
|
|
|
|
stat1.reset();
|
|
CHECK(stat1.n == 0.0);
|
|
|
|
auto timer = stat1.time_start();
|
|
for(int i = 0; i < 20; i++) {
|
|
stat1.sample_time(timer);
|
|
}
|
|
}
|
|
|
|
fuc2::Set TESTS{
|
|
.name="stats",
|
|
.tests={
|
|
TEST(test_basic_stats_tests),
|
|
}
|
|
};
|
|
|
|
}
|