1 /*
2  *  Created by Martin on 30/08/2017.
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_random_number_generator.h"
9 #include "catch_context.h"
10 #include "catch_interfaces_config.h"
11 
12 namespace Catch {
13 
rng()14     std::mt19937& rng() {
15         static std::mt19937 s_rng;
16         return s_rng;
17     }
18 
seedRng(IConfig const & config)19     void seedRng( IConfig const& config ) {
20         if( config.rngSeed() != 0 ) {
21             std::srand( config.rngSeed() );
22             rng().seed( config.rngSeed() );
23         }
24     }
25 
rngSeed()26     unsigned int rngSeed() {
27         return getCurrentContext().getConfig()->rngSeed();
28     }
29 }
30