Skip to content

Commit

Permalink
Fix common_ops_ut (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsayukov committed Aug 14, 2024
1 parent eebe4b0 commit 043286f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions util/random/common_ops_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,24 @@ Y_UNIT_TEST_SUITE(TestCommonRNG) {
}

Y_UNIT_TEST(TestStlCompatibility) {
// NOTE: Check if `TRng` can be passed to `std::normal_distribution::operator()`.
// These tests just have to be compilable, so the asserts below are always true.
{
TRng<ui32> r;
r.C_ = 17;
std::normal_distribution<float> nd(0, 1);
UNIT_ASSERT_DOUBLES_EQUAL(nd(r), -0.877167, 0.01);
UNIT_ASSERT_DOUBLES_EQUAL(nd(r), 0.0, nd.max());
}

{
TRng<ui64> r;
r.C_ = 17;
std::normal_distribution<double> nd(0, 1);
UNIT_ASSERT_DOUBLES_EQUAL(nd(r), -0.5615566731, 0.01);
UNIT_ASSERT_DOUBLES_EQUAL(nd(r), 0.0, nd.max());
}

{
TRng<ui16> r;
r.C_ = 17;
std::normal_distribution<long double> nd(0, 1);
UNIT_ASSERT_DOUBLES_EQUAL(nd(r), -0.430375088, 0.01);
UNIT_ASSERT_DOUBLES_EQUAL(nd(r), 0.0, nd.max());
}
}
}

0 comments on commit 043286f

Please sign in to comment.