Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions include/rapidcheck/gen/Numeric.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#pragma once

#include <complex>

#include "rapidcheck/detail/BitStream.h"
#include "rapidcheck/shrinkable/Create.h"
#include "rapidcheck/shrink/Shrink.h"
#include "rapidcheck/gen/Transform.h"
#include "rapidcheck/gen/Tuple.h"
#include "rapidcheck/gen/detail/ScaleInteger.h"

namespace rc {
Expand Down Expand Up @@ -80,6 +83,18 @@ struct DefaultArbitrary<long double> {
static Gen<long double> arbitrary() { return real<long double>; }
};

template <typename T>
struct DefaultArbitrary<std::complex<T>> {
static Gen<std::complex<T>> arbitrary() {
return gen::map(
gen::pair(
DefaultArbitrary<T>::arbitrary(),
DefaultArbitrary<T>::arbitrary()),
[](std::pair<T, T> pair) { return std::complex<T> (pair.first, pair.second); }
);
}
};

template <>
struct DefaultArbitrary<bool> {
static Gen<bool> arbitrary() { return boolean; }
Expand Down