1 /*
2  *  Created by Martin on 06/10/2019.
3  *
4  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
5  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  */
7 
8 #include "catch.hpp"
9 
10 #include "internal/catch_random_number_generator.h"
11 
12 TEST_CASE("Our PCG implementation provides expected results for known seeds", "[rng]") {
13     Catch::SimplePcg32 rng;
14     SECTION("Default seeded") {
15         REQUIRE(rng() == 0xfcdb943b);
16         REQUIRE(rng() == 0x6f55b921);
17         REQUIRE(rng() == 0x4c17a916);
18         REQUIRE(rng() == 0x71eae25f);
19         REQUIRE(rng() == 0x6ce7909c);
20     }
21     SECTION("Specific seed") {
22         rng.seed(0xabcd1234);
23         REQUIRE(rng() == 0x57c08495);
24         REQUIRE(rng() == 0x33c956ac);
25         REQUIRE(rng() == 0x2206fd76);
26         REQUIRE(rng() == 0x3501a35b);
27         REQUIRE(rng() == 0xfdffb30f);
28 
29         // Also check repeated output after reseeding
30         rng.seed(0xabcd1234);
31         REQUIRE(rng() == 0x57c08495);
32         REQUIRE(rng() == 0x33c956ac);
33         REQUIRE(rng() == 0x2206fd76);
34         REQUIRE(rng() == 0x3501a35b);
35         REQUIRE(rng() == 0xfdffb30f);
36     }
37 }
38 
39 TEST_CASE("Comparison ops", "[rng]") {
40     using Catch::SimplePcg32;
41     REQUIRE(SimplePcg32{} == SimplePcg32{});
42     REQUIRE(SimplePcg32{ 0 } != SimplePcg32{});
43     REQUIRE_FALSE(SimplePcg32{ 1 } == SimplePcg32{ 2 });
44     REQUIRE_FALSE(SimplePcg32{ 1 } != SimplePcg32{ 1 });
45 }
46