You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
573 B
27 lines
573 B
#include <catch2/catch_test_macros.hpp>
|
|
#include "stats.hpp"
|
|
#include "rand.hpp"
|
|
#include <cmath>
|
|
#include <fmt/core.h>
|
|
|
|
TEST_CASE("basic stats tests", "[stats]") {
|
|
Stats stat1;
|
|
stat1.sample(1.0);
|
|
|
|
for(int i = 0; i < 20; i++) {
|
|
double x = Random::normal(20.0,5.0);
|
|
stat1.sample(x);
|
|
REQUIRE(!std::isnan(stat1.stddev()));
|
|
REQUIRE(stat1.mean() < stat1.mean() + stat1.stddev() * 4.0);
|
|
}
|
|
|
|
stat1.dump();
|
|
|
|
stat1.reset();
|
|
REQUIRE(stat1.n == 0.0);
|
|
|
|
auto timer = stat1.time_start();
|
|
for(int i = 0; i < 20; i++) {
|
|
stat1.sample_time(timer);
|
|
}
|
|
}
|
|
|