Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HDembinski committed Apr 25, 2024
1 parent 125340b commit 0dc807c
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions test/accumulators_fraction_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ void run_tests() {

{
f_t f;
BOOST_TEST_EQ(f.successes(), 0);
BOOST_TEST_EQ(f.failures(), 0);
BOOST_TEST_EQ(f.successes(), 0.f);
BOOST_TEST_EQ(f.failures(), 0.f);
BOOST_TEST(std::isnan(f.value()));
BOOST_TEST(std::isnan(f.variance()));

Expand All @@ -38,22 +38,22 @@ void run_tests() {
{
f_t f;
f(true);
BOOST_TEST_EQ(f.successes(), 1);
BOOST_TEST_EQ(f.failures(), 0);
BOOST_TEST_EQ(f.successes(), 1.f);
BOOST_TEST_EQ(f.failures(), 0.f);
BOOST_TEST_EQ(str(f), "fraction(1, 0)"s);
f(false);
BOOST_TEST_EQ(f.successes(), 1);
BOOST_TEST_EQ(f.failures(), 1);
BOOST_TEST_EQ(f.successes(), 1.f);
BOOST_TEST_EQ(f.failures(), 1.f);
BOOST_TEST_EQ(str(f), "fraction(1, 1)"s);
BOOST_TEST_EQ(str(f, 20), "fraction(1, 1) "s);
}

{
f_t f(3, 1);
BOOST_TEST_EQ(f.successes(), 3);
BOOST_TEST_EQ(f.failures(), 1);
BOOST_TEST_EQ(f.value(), 0.75);
BOOST_TEST_IS_CLOSE(f.variance(), 0.75 * (1 - 0.75) / 4, eps);
BOOST_TEST_EQ(f.successes(), 3.f);
BOOST_TEST_EQ(f.failures(), 1.f);
BOOST_TEST_EQ(f.value(), 0.75f);
BOOST_TEST_IS_CLOSE(f.variance(), 0.75f * (1.f - 0.75f) / 4.f, eps);

const auto ci = f.confidence_interval();
const auto expected = utility::wilson_interval<double>()(3, 1);
Expand All @@ -63,10 +63,10 @@ void run_tests() {

{
f_t f(0, 1);
BOOST_TEST_EQ(f.successes(), 0);
BOOST_TEST_EQ(f.failures(), 1);
BOOST_TEST_EQ(f.value(), 0);
BOOST_TEST_EQ(f.variance(), 0);
BOOST_TEST_EQ(f.successes(), 0.f);
BOOST_TEST_EQ(f.failures(), 1.f);
BOOST_TEST_EQ(f.value(), 0.f);
BOOST_TEST_EQ(f.variance(), 0.f);

const auto ci = f.confidence_interval();
const auto expected = utility::wilson_interval<double>()(0, 1);
Expand All @@ -76,10 +76,10 @@ void run_tests() {

{
f_t f(1, 0);
BOOST_TEST_EQ(f.successes(), 1);
BOOST_TEST_EQ(f.failures(), 0);
BOOST_TEST_EQ(f.value(), 1);
BOOST_TEST_EQ(f.variance(), 0);
BOOST_TEST_EQ(f.successes(), 1.f);
BOOST_TEST_EQ(f.failures(), 0.f);
BOOST_TEST_EQ(f.value(), 1.f);
BOOST_TEST_EQ(f.variance(), 0.f);

const auto ci = f.confidence_interval();
const auto expected = utility::wilson_interval<double>()(1, 0);
Expand All @@ -106,8 +106,8 @@ int main() {
using f_t2 = accumulators::fraction<int>;
f_t1 f1(5, 3);
f_t2 f2(f1);
BOOST_TEST_EQ(f2.successes(), 5);
BOOST_TEST_EQ(f2.failures(), 3);
BOOST_TEST_EQ(f2.successes(), 5.f);
BOOST_TEST_EQ(f2.failures(), 3.f);
}

return boost::report_errors();
Expand Down

0 comments on commit 0dc807c

Please sign in to comment.