proxygen
|
#include <chrono>
#include <regex>
#include <system_error>
#include <type_traits>
#include <folly/Conv.h>
#include <folly/ExceptionString.h>
#include <folly/Range.h>
#include <folly/portability/GTest.h>
Go to the source code of this file.
Classes | |
class | folly::test::detail::CheckResult |
Namespaces | |
folly | |
—— Concurrent Priority Queue Implementation —— | |
folly::test | |
folly::test::detail | |
Macros | |
#define | SKIP() return GTEST_SUCCESS_("Test skipped by client") |
#define | SKIP_IF(expr) |
#define | TEST_THROW_ERRNO_(statement, errnoValue, fail) |
#define | EXPECT_THROW_ERRNO(statement, errnoValue) TEST_THROW_ERRNO_(statement, errnoValue, GTEST_NONFATAL_FAILURE_) |
#define | ASSERT_THROW_ERRNO(statement, errnoValue) TEST_THROW_ERRNO_(statement, errnoValue, GTEST_FATAL_FAILURE_) |
#define | TEST_THROW_RE_(statement, exceptionType, pattern, fail) |
#define | EXPECT_THROW_RE(statement, exceptionType, pattern) TEST_THROW_RE_(statement, exceptionType, pattern, GTEST_NONFATAL_FAILURE_) |
#define | ASSERT_THROW_RE(statement, exceptionType, pattern) TEST_THROW_RE_(statement, exceptionType, pattern, GTEST_FATAL_FAILURE_) |
Functions | |
template<typename T1 , typename T2 > | |
::testing::AssertionResult | folly::test::AreWithinSecs (T1 val1, T2 val2, std::chrono::seconds acceptableDeltaSecs) |
template<typename Fn > | |
CheckResult | folly::test::detail::checkThrowErrno (Fn &&fn, int errnoValue, const char *statementStr) |
template<typename ExType , typename Fn > | |
CheckResult | folly::test::detail::checkThrowRegex (Fn &&fn, const char *pattern, const char *statementStr, const char *excTypeStr) |
void | folly::PrintTo (StringPiece sp,::std::ostream *os) |
#define ASSERT_THROW_ERRNO | ( | statement, | |
errnoValue | |||
) | TEST_THROW_ERRNO_(statement, errnoValue, GTEST_FATAL_FAILURE_) |
Definition at line 88 of file TestUtils.h.
#define ASSERT_THROW_RE | ( | statement, | |
exceptionType, | |||
pattern | |||
) | TEST_THROW_RE_(statement, exceptionType, pattern, GTEST_FATAL_FAILURE_) |
Definition at line 121 of file TestUtils.h.
#define EXPECT_THROW_ERRNO | ( | statement, | |
errnoValue | |||
) | TEST_THROW_ERRNO_(statement, errnoValue, GTEST_NONFATAL_FAILURE_) |
Check that a statement throws a std::system_error with the expected errno value. This is useful for checking code that uses the functions in folly/Exception.h to throw exceptions.
Like other EXPECT_* and ASSERT_* macros, additional message information can be included using the << stream operator.
Example usage:
EXPECT_THROW_ERRNO(readFile("notpresent.txt"), ENOENT) << "notpresent.txt should not exist";
Definition at line 86 of file TestUtils.h.
#define EXPECT_THROW_RE | ( | statement, | |
exceptionType, | |||
pattern | |||
) | TEST_THROW_RE_(statement, exceptionType, pattern, GTEST_NONFATAL_FAILURE_) |
Check that a statement throws the expected exception type, and that the exception message matches the specified regular expression.
Partial matches (against just a portion of the error message) are accepted if the regular expression does not explicitly start with "^" and end with "$". (The matching is performed using std::regex_search() rather than std::regex_match().)
This uses ECMA-262 style regular expressions (the default behavior of std::regex).
Like other EXPECT_* and ASSERT_* macros, additional message information can be included using the << stream operator.
Example usage:
EXPECT_THROW_RE(badFunction(), std::runtime_error, "oh noes") << "function did not throw the expected exception";
Definition at line 119 of file TestUtils.h.
Referenced by TEST().
#define SKIP | ( | ) | return GTEST_SUCCESS_("Test skipped by client") |
Definition at line 55 of file TestUtils.h.
Referenced by TEST().
#define SKIP_IF | ( | expr | ) |
Definition at line 59 of file TestUtils.h.
Referenced by TEST().
#define TEST_THROW_ERRNO_ | ( | statement, | |
errnoValue, | |||
fail | |||
) |
Definition at line 65 of file TestUtils.h.
#define TEST_THROW_RE_ | ( | statement, | |
exceptionType, | |||
pattern, | |||
fail | |||
) |
Definition at line 91 of file TestUtils.h.