Now fully off catch2. YAY!
This commit is contained in:
parent
903cf00661
commit
21e7700deb
16 changed files with 610 additions and 498 deletions
|
|
@ -1,27 +1,40 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fuc2/testing.hpp>
|
||||
#include "algos/stats.hpp"
|
||||
#include "algos/rand.hpp"
|
||||
#include <cmath>
|
||||
#include <fmt/core.h>
|
||||
|
||||
TEST_CASE("basic stats tests", "[stats]") {
|
||||
Stats stat1;
|
||||
stat1.sample(1.0);
|
||||
using namespace fuc2;
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
stat1.dump();
|
||||
fuc2::Set TESTS{
|
||||
.name="stats",
|
||||
.tests={
|
||||
TEST(test_basic_stats_tests),
|
||||
}
|
||||
};
|
||||
|
||||
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