Now have a simple stats test.
This commit is contained in:
parent
d3158291f7
commit
0efb17371b
4 changed files with 37 additions and 10 deletions
27
tests/stats.cpp
Normal file
27
tests/stats.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue