From 775441147a94cb5e06bfdfe3859455354d42f33e Mon Sep 17 00:00:00 2001 From: Yair Chuchem Date: Wed, 29 Aug 2018 00:56:12 +0300 Subject: [PATCH] arbitrary instance for std::complex (#11) --- include/rapidcheck/gen/Numeric.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/rapidcheck/gen/Numeric.hpp b/include/rapidcheck/gen/Numeric.hpp index 6954c973..ed89c186 100644 --- a/include/rapidcheck/gen/Numeric.hpp +++ b/include/rapidcheck/gen/Numeric.hpp @@ -1,9 +1,12 @@ #pragma once +#include + #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 { @@ -80,6 +83,18 @@ struct DefaultArbitrary { static Gen arbitrary() { return real; } }; +template +struct DefaultArbitrary> { + static Gen> arbitrary() { + return gen::map( + gen::pair( + DefaultArbitrary::arbitrary(), + DefaultArbitrary::arbitrary()), + [](std::pair pair) { return std::complex (pair.first, pair.second); } + ); + } +}; + template <> struct DefaultArbitrary { static Gen arbitrary() { return boolean; }