1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00
VILLASnode/common/tests/unit/hist.cpp
Alexandra b39e4a0ace feat: new smu node-type
Signed-off-by: Alexandra <alexandra.bach@eonerc.rwth-aachen.de>
2025-01-14 14:42:39 +00:00

32 lines
784 B
C++

/* Unit tests for histogram.
*
* Author: Steffen Vogel <post@steffenvogel.de>
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
* SPDX-License-Identifier: Apache-2.0
*/
#include <array>
#include <criterion/criterion.h>
#include <villas/hist.hpp>
#include <villas/utils.hpp>
const std::array<double, 10> test_data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
using namespace villas;
// cppcheck-suppress unknownMacro
TestSuite(hist, .description = "Histogram");
Test(hist, simple) {
Hist h(10, 2);
for (auto td : test_data)
h.put(td);
cr_assert_float_eq(h.getMean(), 5.5, 1e-6, "Mean is %lf", h.getMean());
cr_assert_float_eq(h.getVar(), 9.1666, 1e-3);
cr_assert_float_eq(h.getStddev(), 3.027650, 1e-6);
}