1 #include "gmock/internal/gmock-pp.h" 2 3 // Static assertions. 4 namespace testing { 5 namespace internal { 6 namespace gmockpp { 7 8 static_assert(GMOCK_PP_CAT(1, 4) == 14, ""); 9 static_assert(GMOCK_PP_INTERNAL_INTERNAL_16TH(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10 12, 13, 14, 15, 16, 17, 18) == 16, 11 ""); 12 static_assert(GMOCK_PP_NARG() == 1, ""); 13 static_assert(GMOCK_PP_NARG(x) == 1, ""); 14 static_assert(GMOCK_PP_NARG(x, y) == 2, ""); 15 static_assert(GMOCK_PP_NARG(x, y, z) == 3, ""); 16 static_assert(GMOCK_PP_NARG(x, y, z, w) == 4, ""); 17 static_assert(!GMOCK_PP_HAS_COMMA(), ""); 18 static_assert(GMOCK_PP_HAS_COMMA(b, ), ""); 19 static_assert(!GMOCK_PP_HAS_COMMA((, )), ""); 20 static_assert(!GMOCK_PP_IS_EMPTY(, ), ""); 21 static_assert(!GMOCK_PP_IS_EMPTY(a), ""); 22 static_assert(!GMOCK_PP_IS_EMPTY(()), ""); 23 static_assert(GMOCK_PP_IF(1, 1, 2) == 1, ""); 24 static_assert(GMOCK_PP_IF(0, 1, 2) == 2, ""); 25 static_assert(GMOCK_PP_NARG0(x) == 1, ""); 26 static_assert(GMOCK_PP_NARG0(x, y) == 2, ""); 27 static_assert(GMOCK_PP_HEAD(1) == 1, ""); 28 static_assert(GMOCK_PP_HEAD(1, 2) == 1, ""); 29 static_assert(GMOCK_PP_HEAD(1, 2, 3) == 1, ""); 30 static_assert(GMOCK_PP_TAIL(1, 2) == 2, ""); 31 static_assert(GMOCK_PP_HEAD(GMOCK_PP_TAIL(1, 2, 3)) == 2, ""); 32 static_assert(!GMOCK_PP_IS_BEGIN_PARENS(sss), ""); 33 static_assert(!GMOCK_PP_IS_BEGIN_PARENS(sss()), ""); 34 static_assert(!GMOCK_PP_IS_BEGIN_PARENS(sss() sss), ""); 35 static_assert(GMOCK_PP_IS_BEGIN_PARENS((sss)), ""); 36 static_assert(GMOCK_PP_IS_BEGIN_PARENS((sss)ss), ""); 37 static_assert(!GMOCK_PP_IS_ENCLOSED_PARENS(sss), ""); 38 static_assert(!GMOCK_PP_IS_ENCLOSED_PARENS(sss()), ""); 39 static_assert(!GMOCK_PP_IS_ENCLOSED_PARENS(sss() sss), ""); 40 static_assert(!GMOCK_PP_IS_ENCLOSED_PARENS((sss)ss), ""); 41 static_assert(GMOCK_PP_REMOVE_PARENS((1 + 1)) * 2 == 3, ""); 42 static_assert(GMOCK_PP_INC(4) == 5, ""); 43 44 template <class... Args> 45 struct Test { 46 static constexpr int kArgs = sizeof...(Args); 47 }; 48 #define GMOCK_PP_INTERNAL_TYPE_TEST(_i, _Data, _element) \ 49 GMOCK_PP_COMMA_IF(_i) _element 50 static_assert(Test<GMOCK_PP_FOR_EACH(GMOCK_PP_INTERNAL_TYPE_TEST, ~, 51 (int, float, double, char))>::kArgs == 4, 52 ""); 53 #define GMOCK_PP_INTERNAL_VAR_TEST_1(_x) 1 54 #define GMOCK_PP_INTERNAL_VAR_TEST_2(_x, _y) 2 55 #define GMOCK_PP_INTERNAL_VAR_TEST_3(_x, _y, _z) 3 56 57 #define GMOCK_PP_INTERNAL_VAR_TEST(...) \ 58 GMOCK_PP_VARIADIC_CALL(GMOCK_PP_INTERNAL_VAR_TEST_, __VA_ARGS__) 59 static_assert(GMOCK_PP_INTERNAL_VAR_TEST(x, y) == 2, ""); 60 static_assert(GMOCK_PP_INTERNAL_VAR_TEST(silly) == 1, ""); 61 static_assert(GMOCK_PP_INTERNAL_VAR_TEST(x, y, z) == 3, ""); 62 63 // TODO(iserna): The following asserts fail in --config=lexan. 64 #define GMOCK_PP_INTERNAL_IS_EMPTY_TEST_1 65 static_assert(GMOCK_PP_IS_EMPTY(GMOCK_PP_INTERNAL_IS_EMPTY_TEST_1), ""); 66 static_assert(GMOCK_PP_IS_EMPTY(), ""); 67 static_assert(GMOCK_PP_IS_ENCLOSED_PARENS((sss)), ""); 68 static_assert(GMOCK_PP_IS_EMPTY(GMOCK_PP_TAIL(1)), ""); 69 static_assert(GMOCK_PP_NARG0() == 0, ""); 70 71 } // namespace gmockpp 72 } // namespace internal 73 } // namespace testing 74