Created
August 10, 2020 12:37
-
-
Save objectx/8279b3bf1cba6864a1b4fee24fb5dfc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @brief Helper function for using the `rapidcheck` under the `doctest`. | |
#pragma once | |
#include <doctest/doctest.h> | |
#include <rapidcheck.h> | |
#include <utility> | |
namespace rc { | |
template <typename Testable_> | |
void prop (const std::string &description, Testable_ &&testable) { | |
using namespace detail; | |
DOCTEST_SUBCASE(description.c_str()) { | |
const auto result = checkTestable(std::forward<Testable_>(testable)); | |
if (result.template is<SuccessResult> ()) { | |
const auto success = result.template get<SuccessResult> (); | |
if (! success.distribution.empty ()) { | |
std::cout << "- " << description << '\n'; | |
printResultMessage (result, std::cout); | |
std::cout << std::endl; | |
} | |
} | |
else { | |
std::ostringstream ss; | |
printResultMessage (result, ss); | |
DOCTEST_FAIL_CHECK (ss.str() << "\n"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment