/* Unit tests for histogram. * * Author: Steffen Vogel * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University * SPDX-License-Identifier: Apache-2.0 */ #include #include #include #include const std::array 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); }