1// Copyright 2022 Hans Dembinski
2//
3// Distributed under the Boost Software License, Version 1.0.
4// (See accompanying file LICENSE_1_0.txt
5// or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7#include <boost/core/lightweight_test.hpp>
8#include <boost/histogram/accumulators/fraction.hpp>
9#include <boost/histogram/utility/wald_interval.hpp>
10#include <limits>
11#include "is_close.hpp"
12#include "throw_exception.hpp"
13
14using namespace boost::histogram::utility;
15using namespace boost::histogram::accumulators;
16
17int main() {
18
19 const double atol = std::numeric_limits<double>::epsilon();
20
21 wald_interval<> iv(deviation{1});
22
23 {
24 const auto x = iv(0, 1);
25 BOOST_TEST_IS_CLOSE(x.first, 0.0, atol);
26 BOOST_TEST_IS_CLOSE(x.second, 0.0, atol);
27
28 fraction<> f(0, 1);
29 const auto y = iv(f);
30 BOOST_TEST_IS_CLOSE(y.first, 0.0, atol);
31 BOOST_TEST_IS_CLOSE(y.second, 0.0, atol);
32 }
33
34 {
35 const auto x = iv(1, 0);
36 BOOST_TEST_IS_CLOSE(x.first, 1.0, atol);
37 BOOST_TEST_IS_CLOSE(x.second, 1.0, atol);
38
39 fraction<> f(1, 0);
40 const auto y = iv(f);
41 BOOST_TEST_IS_CLOSE(y.first, 1.0, atol);
42 BOOST_TEST_IS_CLOSE(y.second, 1.0, atol);
43 }
44
45 {
46 const auto x = iv(5, 5);
47 BOOST_TEST_IS_CLOSE(x.first, 0.341886116991581, atol);
48 BOOST_TEST_IS_CLOSE(x.second, 0.658113883008419, atol);
49 }
50
51 {
52 const auto x = iv(1, 9);
53 BOOST_TEST_IS_CLOSE(x.first, 0.005131670194948618, atol);
54 BOOST_TEST_IS_CLOSE(x.second, 0.1948683298050514, atol);
55 }
56
57 {
58 const auto x = iv(9, 1);
59 BOOST_TEST_IS_CLOSE(x.first, 0.8051316701949487, atol);
60 BOOST_TEST_IS_CLOSE(x.second, 0.9948683298050514, atol);
61 }
62
63 return boost::report_errors();
64}
65

source code of boost/libs/histogram/test/utility_wald_interval_test.cpp