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_RANDOM_GENERATOR_H_
16 #define SOURCE_FUZZ_RANDOM_GENERATOR_H_
17 
18 #include <stdint.h>
19 
20 namespace spvtools {
21 namespace fuzz {
22 
23 class RandomGenerator {
24  public:
25   RandomGenerator();
26 
27   virtual ~RandomGenerator();
28 
29   // Returns a value in the half-open interval [0, bound).
30   virtual uint32_t RandomUint32(uint32_t bound) = 0;
31 
32   // Returns a value in the half-open interval [0, bound).
33   virtual uint64_t RandomUint64(uint64_t bound) = 0;
34 
35   // Returns a value in the closed interval [0, 100].
36   virtual uint32_t RandomPercentage() = 0;
37 
38   // Returns a boolean.
39   virtual bool RandomBool() = 0;
40 
41   // Returns a double in the closed interval [0, 1]
42   virtual double RandomDouble() = 0;
43 };
44 
45 }  // namespace fuzz
46 }  // namespace spvtools
47 
48 #endif  // SOURCE_FUZZ_RANDOM_GENERATOR_H_
49