1 // Copyright (c) 2019 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SOURCE_FUZZ_PSEUDO_RANDOM_GENERATOR_H_
16 #define SOURCE_FUZZ_PSEUDO_RANDOM_GENERATOR_H_
17 
18 #include <random>
19 
20 #include "source/fuzz/random_generator.h"
21 
22 namespace spvtools {
23 namespace fuzz {
24 
25 // Generates random data from a pseudo-random number generator.
26 class PseudoRandomGenerator : public RandomGenerator {
27  public:
28   explicit PseudoRandomGenerator(uint32_t seed);
29 
30   ~PseudoRandomGenerator() override;
31 
32   uint32_t RandomUint32(uint32_t bound) override;
33 
34   uint64_t RandomUint64(uint64_t bound) override;
35 
36   uint32_t RandomPercentage() override;
37 
38   bool RandomBool() override;
39 
40   double RandomDouble() override;
41 
42  private:
43   std::mt19937 mt_;
44 };
45 
46 }  // namespace fuzz
47 }  // namespace spvtools
48 
49 #endif  // SOURCE_FUZZ_PSEUDO_RANDOM_GENERATOR_H_
50