| 123456789101112131415161718192021222324252627282930313233343536373839 |
- //
- // 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_APPLY_DEVICE(T) \
- T apply(Distribution<T> const & dist) final { \
- std::stringstream ss; \
- ss << dist; \
- return CONCAT(apply_, T)(ss.str()); \
- } \
- MOCK_METHOD1(CONCAT(apply_, T), T(std::string const &))
- namespace engine::random {
- class MockDevice : public Device {
- public:
- result_type operator()() final { return apply_uint32_t("?"); }
- MOCK_APPLY_DEVICE(size_t);
- MOCK_APPLY_DEVICE(double);
- MOCK_APPLY_DEVICE(int32_t);
- MOCK_APPLY_DEVICE(uint32_t);
- };
- }
|