Function check

Summary

#include <include/rapidcheck/Check.h>

(1) template <typename Testable>
    bool check(Testable &&testable)

(2) template <typename Testable>
    bool check(const std::string &description, Testable &&testable)

Function overload

Synopsis

#include <include/rapidcheck/Check.h>

template <typename Testable>
bool check(Testable &&testable)

Description

Checks the given testable and returns true on success and false on failure. This method will also print information about the testing to stderr.

Mentioned in

Source

Lines 43-46 in include/rapidcheck/Check.hpp. Line 11 in include/rapidcheck/Check.h.

template <typename Testable>
bool check(Testable &&testable) {
  return check(std::string(), std::forward<Testable>(testable));
}

Synopsis

#include <include/rapidcheck/Check.h>

template <typename Testable>
bool check(const std::string &description, Testable &&testable)

Description

Same as check(Testable &&) but also takes a description of the property that is being tested as the first parameter. This will be used in the output.

Mentioned in

Source

Lines 48-70 in include/rapidcheck/Check.hpp. Line 17 in include/rapidcheck/Check.h.

template <typename Testable>
bool check(const std::string &description, Testable &&testable) {
  using namespace rc::detail;

  // Force loading of the configuration so that message comes _before_ the
  // description
  configuration();

  if (!description.empty()) {
    std::cerr << std::endl << "- " << description << std::endl;
  }

  TestMetadata metadata;
  metadata.id = description;
  metadata.description = description;
  const auto result =
      detail::checkTestable(std::forward<Testable>(testable), metadata);

  printResultMessage(result, std::cerr);
  std::cerr << std::endl;

  return result.template is<detail::SuccessResult>();
}





Add Discussion as Guest

Log in