X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Ftest%2FTestUtils.h;h=62085ff8c23d65852c438c352734dc85567e17e6;hp=6eb7a0b9d048324aa02012ee76ab81e5495cf581;hb=492fad43a76506407008a5394511daf6bba5bccc;hpb=6746259314362d89f3d1d1dbfdf00c9fe18de202 diff --git a/folly/test/TestUtils.h b/folly/test/TestUtils.h index 6eb7a0b9..62085ff8 100644 --- a/folly/test/TestUtils.h +++ b/folly/test/TestUtils.h @@ -19,7 +19,7 @@ /* * This file contains additional gtest-style check macros to use in unit tests. * - * - SKIP() + * - SKIP(), SKIP_IF(EXPR) * - EXPECT_THROW_RE(), ASSERT_THROW_RE() * - EXPECT_THROW_ERRNO(), ASSERT_THROW_ERRNO() * - AreWithinSecs() @@ -46,6 +46,13 @@ // interprets the message. #define SKIP() GTEST_FATAL_FAILURE_("Test skipped by client") +// Encapsulate conditional-skip, since it's nontrivial to get right. +#define SKIP_IF(expr) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (!(expr)) { \ + } else \ + SKIP() + #define TEST_THROW_ERRNO_(statement, errnoValue, fail) \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ if (::folly::test::detail::CheckResult gtest_result = \