rapidcheck icon indicating copy to clipboard operation
rapidcheck copied to clipboard

Polymorphic containers and std::function support

Open elefthei opened this issue 5 years ago • 0 comments

Hello,

Thanks for rapidcheck, its great both in API and performance. I was wondering what is the recommended way of testing polymorphic containers, something like:

// Here some type level assumption that T has the empty() method would be great, maybe:
template<typename T, typename = std::enable_if_t<is_monoid_v<T>>>
rc::check("Poly list", [](const std::list<T>& l) {
    l.push_front(T());
    return l.front().empty();
}

Or maybe RC_ASSERT can be used. Or perhaps some inheritance trick, making monoid a class and saying that pick an arbitrary T such that T subclasses a Monoid class. If there exists a way exists to check polymorphic types, that would be great!

Also this is a long shot, but is there any way I can get arbitrary std::function objects?

elefthei avatar Oct 12 '18 18:10 elefthei