| 123456789101112131415161718192021222324252627282930313233343536 |
- //
- // mock_device.h
- // shared_random_generator
- //
- // Created by Sam Jaffe on 3/25/23.
- // Copyright © 2023 Sam Jaffe. All rights reserved.
- //
- #pragma once
- #include <sstream>
- #include <gmock/gmock.h>
- #include <random/device.h>
- #include <random/distribution.h>
- #ifndef CONCAT
- #define CONCAT2(A, B) A##B
- #define CONCAT(A, B) CONCAT2(A, B)
- #endif
- #define MOCK_DEVICE(T) \
- MOCK_METHOD1(CONCAT(apply_, T), T(std::string const &)); \
- T apply(Distribution<T> const & dist) final { \
- return CONCAT(apply_, T)(to_string(dist)); \
- }
- namespace engine::random {
- class MockDevice : public Device {
- public:
- result_type operator()() final { return apply_uint32_t("?"); }
- IMPLEMENT_DEVICE(MOCK_DEVICE)
- };
- }
- #undef MOCK_DEVICE
|