summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-23 08:45:13 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-23 11:17:34 +0000
commit5a9425af92bef565f162d362c94433cc0d053789 (patch)
tree88ad0c2d91c183d27c96daf72917b7a9caaf15ad
parent0e123c297ac3a6b4ea98af6834ddf847ce0a4fc5 (diff)
make B2DPolyPolygonTest deterministic
Change-Id: Ia8071285d70b39b21b1312d461dc8d502d5cb305 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147497 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--basegfx/test/B2DPolyPolygonTest.cxx12
1 files changed, 10 insertions, 2 deletions
diff --git a/basegfx/test/B2DPolyPolygonTest.cxx b/basegfx/test/B2DPolyPolygonTest.cxx
index 1fef45328357..f51d396b8578 100644
--- a/basegfx/test/B2DPolyPolygonTest.cxx
+++ b/basegfx/test/B2DPolyPolygonTest.cxx
@@ -25,11 +25,10 @@
#include <basegfx/polygon/b2dtrapezoid.hxx>
#include "boxclipper.hxx"
+#include <random>
namespace basegfx
{
-using ::basegfx2d::getRandomOrdinal;
-
class b2dpolypolygon : public CppUnit::TestFixture
{
public:
@@ -65,6 +64,15 @@ public:
CPPUNIT_ASSERT_MESSAGE("more than zero sub-divided trapezoids", !aVector.empty());
}
+ std::mt19937 rng; // Standard mersenne_twister_engine
+
+ /// Gets a random ordinal [0,n)
+ ::std::size_t getRandomOrdinal(const ::std::size_t n)
+ {
+ std::uniform_int_distribution<size_t> dist(0, n - 1);
+ return dist(rng);
+ }
+
// Change the following lines only, if you add, remove or rename
// member functions of the current class,
// because these macros are need by auto register mechanism.