random_generator.h 1.4 KB

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