summaryrefslogtreecommitdiffstats
path: root/tests/test_rand.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:39:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:39:03 +0000
commit408c608fc7bf1557ee987dd7fbe662fabed21a53 (patch)
tree8b07135336de378134bfedc808d49747174810d3 /tests/test_rand.cpp
parentInitial commit. (diff)
downloadfrozen-upstream.tar.xz
frozen-upstream.zip
Adding upstream version 1.1.1.upstream/1.1.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_rand.cpp')
-rw-r--r--tests/test_rand.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_rand.cpp b/tests/test_rand.cpp
new file mode 100644
index 0000000..eac94ec
--- /dev/null
+++ b/tests/test_rand.cpp
@@ -0,0 +1,40 @@
+#include <algorithm>
+#include <frozen/random.h>
+#include <iostream>
+#include <random>
+
+#include "bench.hpp"
+#include "catch.hpp"
+
+TEST_CASE("linear_congruential_engine", "[random]") {
+
+ frozen::linear_congruential_engine<std::uint32_t, 48271u, 0, 0x7fffffff> dist0;
+ std::linear_congruential_engine<std::uint32_t, 48271u, 0, 0x7fffffff> rdist0;
+ REQUIRE(dist0.min() == rdist0.min());
+ REQUIRE(dist0.max() == rdist0.max());
+ REQUIRE(dist0() == rdist0());
+ REQUIRE(dist0() == rdist0());
+ REQUIRE(dist0() == rdist0());
+
+ auto next0 = dist0();
+ (void) next0;
+ dist0.discard(3);
+ rdist0.discard(4);
+ REQUIRE(dist0() == rdist0());
+
+ frozen::linear_congruential_engine<std::uint32_t, 48271u, 0, 0x7fffffff> odist0;
+ std::linear_congruential_engine<std::uint32_t, 48271u, 0, 0x7fffffff> ordist0;
+ REQUIRE(rdist0() != ordist0());
+ REQUIRE(dist0() != odist0());
+ REQUIRE(!(dist0() == odist0()));
+
+
+ frozen::minstd_rand dist1;
+ (void)dist1;
+ frozen::minstd_rand dist2;
+ (void)dist2;
+ frozen::linear_congruential_engine<std::size_t, 3, 3, 0> dist3;
+ (void)dist3;
+
+}
+