]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Adjust tests to work for -D_GLIBCXX_USE_OLD_GENERATE_CANONICAL
authorJonathan Wakely <jwakely@redhat.com>
Wed, 17 Dec 2025 13:58:21 +0000 (13:58 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 17 Dec 2025 20:41:31 +0000 (20:41 +0000)
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.

libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc
libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon.cc

index 80818df855e82fbb4e7826b750cabcb916b807ee..3031984df15a4e17e46627133cf49d0295038097 100644 (file)
 #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();
 }
index 40061daa31c01ff7180485d3f90ccd6ca9407f59..87ad206a78a464de013e66755fff77881d0667b2 100644 (file)
@@ -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.