mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 03:47:02 -05:00
libstdc++: Adjust tests to work for -D_GLIBCXX_USE_OLD_GENERATE_CANONICAL
libstdc++-v3/ChangeLog: * testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc [_GLIBCXX_USE_OLD_GENERATE_CANONICAL]: Restore test01. Do not discard an extra value in test02. * testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon.cc: Skip if _GLIBCXX_USE_OLD_GENERATE_CANONICAL is defined in options.
This commit is contained in:
committed by
Jonathan Wakely
parent
c504ab2de5
commit
53893d44f3
@@ -21,6 +21,25 @@
|
||||
#include <random>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
// libstdc++/64351
|
||||
void
|
||||
test01()
|
||||
{
|
||||
#ifdef _GLIBCXX_USE_OLD_GENERATE_CANONICAL
|
||||
std::mt19937 rng(8890);
|
||||
std::uniform_real_distribution<float> dist;
|
||||
|
||||
rng.discard(30e6);
|
||||
for (long i = 0; i < 10e6; ++i)
|
||||
{
|
||||
auto n = dist(rng);
|
||||
VERIFY( n != 1.f );
|
||||
}
|
||||
#else
|
||||
// New generate_canonical is tested in ./gencanon.cc
|
||||
#endif
|
||||
}
|
||||
|
||||
// libstdc++/63176
|
||||
void
|
||||
test02()
|
||||
@@ -37,13 +56,19 @@ test02()
|
||||
|
||||
rng2.discard(1);
|
||||
}
|
||||
|
||||
// PR libstdc++/80137
|
||||
#ifdef _GLIBCXX_USE_OLD_GENERATE_CANONICAL
|
||||
// Each std::generate_canonical call should consume exactly one value.
|
||||
#else
|
||||
rng2.discard(1); // account for a 1.0 generated and discarded.
|
||||
#endif
|
||||
VERIFY( rng == rng2 );
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// { dg-do run { target { c++11 && { ! simulator } } } }
|
||||
// { dg-skip-if "requires new impl" { *-*-* } { -D_GLIBCXX_USE_OLD_GENERATE_CANONICAL -D_GLIBCXX_USE_OLD_GENERATE_CANONICAL=1 } }
|
||||
|
||||
#include <random>
|
||||
#include <limits>
|
||||
@@ -17,7 +18,7 @@ struct local_rng : std::mt19937
|
||||
local_rng(std::mt19937 const& arg) : std::mt19937(arg) {}
|
||||
};
|
||||
|
||||
// Verify P0952R9 implementation requiring a second round-trip
|
||||
// Verify P0952R2 implementation requiring a second round-trip
|
||||
// if first yields exactly 1. In this test, the RNG delivering
|
||||
// 32 bits per call is seeded such that this occurs once on the
|
||||
// sixth iteration for float, and not at all for double.
|
||||
|
||||
Reference in New Issue
Block a user