Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gmock-pp_test.cc
Go to the documentation of this file.
2 
3 // Used to test MSVC treating __VA_ARGS__ with a comma in it as one value
4 #define GMOCK_TEST_REPLACE_comma_WITH_COMMA_I_comma ,
5 #define GMOCK_TEST_REPLACE_comma_WITH_COMMA(x) \
6  GMOCK_PP_CAT(GMOCK_TEST_REPLACE_comma_WITH_COMMA_I_, x)
7 
8 // Static assertions.
9 namespace testing {
10 namespace internal {
11 namespace gmockpp {
12 
13 static_assert(GMOCK_PP_CAT(1, 4) == 14, "");
14 static_assert(GMOCK_PP_INTERNAL_INTERNAL_16TH(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
15  12, 13, 14, 15, 16, 17, 18) == 16,
16  "");
17 static_assert(GMOCK_PP_NARG() == 1, "");
18 static_assert(GMOCK_PP_NARG(x) == 1, "");
19 static_assert(GMOCK_PP_NARG(x, y) == 2, "");
20 static_assert(GMOCK_PP_NARG(x, y, z) == 3, "");
21 static_assert(GMOCK_PP_NARG(x, y, z, w) == 4, "");
22 static_assert(!GMOCK_PP_HAS_COMMA(), "");
23 static_assert(GMOCK_PP_HAS_COMMA(b, ), "");
24 static_assert(!GMOCK_PP_HAS_COMMA((, )), "");
26  "");
27 static_assert(
29  "");
30 static_assert(!GMOCK_PP_IS_EMPTY(, ), "");
31 static_assert(!GMOCK_PP_IS_EMPTY(a), "");
32 static_assert(!GMOCK_PP_IS_EMPTY(()), "");
33 static_assert(GMOCK_PP_IF(1, 1, 2) == 1, "");
34 static_assert(GMOCK_PP_IF(0, 1, 2) == 2, "");
35 static_assert(GMOCK_PP_NARG0(x) == 1, "");
36 static_assert(GMOCK_PP_NARG0(x, y) == 2, "");
37 static_assert(GMOCK_PP_HEAD(1) == 1, "");
38 static_assert(GMOCK_PP_HEAD(1, 2) == 1, "");
39 static_assert(GMOCK_PP_HEAD(1, 2, 3) == 1, "");
40 static_assert(GMOCK_PP_TAIL(1, 2) == 2, "");
41 static_assert(GMOCK_PP_HEAD(GMOCK_PP_TAIL(1, 2, 3)) == 2, "");
42 static_assert(!GMOCK_PP_IS_BEGIN_PARENS(sss), "");
43 static_assert(!GMOCK_PP_IS_BEGIN_PARENS(sss()), "");
44 static_assert(!GMOCK_PP_IS_BEGIN_PARENS(sss() sss), "");
45 static_assert(GMOCK_PP_IS_BEGIN_PARENS((sss)), "");
46 static_assert(GMOCK_PP_IS_BEGIN_PARENS((sss)ss), "");
47 static_assert(!GMOCK_PP_IS_ENCLOSED_PARENS(sss), "");
48 static_assert(!GMOCK_PP_IS_ENCLOSED_PARENS(sss()), "");
49 static_assert(!GMOCK_PP_IS_ENCLOSED_PARENS(sss() sss), "");
50 static_assert(!GMOCK_PP_IS_ENCLOSED_PARENS((sss)ss), "");
51 static_assert(GMOCK_PP_REMOVE_PARENS((1 + 1)) * 2 == 3, "");
52 static_assert(GMOCK_PP_INC(4) == 5, "");
53 
54 template <class... Args>
55 struct Test {
56  static constexpr int kArgs = sizeof...(Args);
57 };
58 #define GMOCK_PP_INTERNAL_TYPE_TEST(_i, _Data, _element) \
59  GMOCK_PP_COMMA_IF(_i) _element
61  (int, float, double, char))>::kArgs == 4,
62  "");
63 #define GMOCK_PP_INTERNAL_VAR_TEST_1(_x) 1
64 #define GMOCK_PP_INTERNAL_VAR_TEST_2(_x, _y) 2
65 #define GMOCK_PP_INTERNAL_VAR_TEST_3(_x, _y, _z) 3
66 
67 #define GMOCK_PP_INTERNAL_VAR_TEST(...) \
68  GMOCK_PP_VARIADIC_CALL(GMOCK_PP_INTERNAL_VAR_TEST_, __VA_ARGS__)
69 static_assert(GMOCK_PP_INTERNAL_VAR_TEST(x, y) == 2, "");
70 static_assert(GMOCK_PP_INTERNAL_VAR_TEST(silly) == 1, "");
71 static_assert(GMOCK_PP_INTERNAL_VAR_TEST(x, y, z) == 3, "");
72 
73 // TODO(iserna): The following asserts fail in --config=lexan.
74 #define GMOCK_PP_INTERNAL_IS_EMPTY_TEST_1
76 static_assert(GMOCK_PP_IS_EMPTY(), "");
77 static_assert(GMOCK_PP_IS_ENCLOSED_PARENS((sss)), "");
78 static_assert(GMOCK_PP_IS_EMPTY(GMOCK_PP_TAIL(1)), "");
79 static_assert(GMOCK_PP_NARG0() == 0, "");
80 
81 } // namespace gmockpp
82 } // namespace internal
83 } // namespace testing
#define GMOCK_PP_IS_BEGIN_PARENS(...)
Definition: gmock-pp.h:115
#define GMOCK_PP_HAS_COMMA(...)
Definition: gmock-pp.h:35
#define GMOCK_PP_INTERNAL_INTERNAL_16TH(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16,...)
Definition: gmock-pp.h:167
#define GMOCK_PP_FOR_EACH(_Macro, _Data, _Tuple)
Definition: gmock-pp.h:131
#define GMOCK_PP_IS_EMPTY(...)
Definition: gmock-pp.h:79
#define GMOCK_PP_INTERNAL_VAR_TEST(...)
#define GMOCK_PP_TAIL(...)
Definition: gmock-pp.h:44
#define GMOCK_PP_CAT(_1, _2)
Definition: gmock-pp.h:5
#define GMOCK_PP_NARG(...)
Definition: gmock-pp.h:29
Uncopyable z
#define GMOCK_PP_REMOVE_PARENS(...)
Definition: gmock-pp.h:125
#define GMOCK_PP_HEAD(...)
Definition: gmock-pp.h:40
#define GMOCK_PP_IF(_Cond, _Then, _Else)
Definition: gmock-pp.h:86
#define GMOCK_PP_INC(_i)
Definition: gmock-pp.h:144
#define GMOCK_PP_INTERNAL_TYPE_TEST(_i, _Data, _element)
#define GMOCK_PP_NARG0(...)
Definition: gmock-pp.h:110
#define GMOCK_PP_IS_ENCLOSED_PARENS(...)
Definition: gmock-pp.h:120
#define GMOCK_TEST_REPLACE_comma_WITH_COMMA(x)
Definition: gmock-pp_test.cc:5
const double y
#define GMOCK_PP_INTERNAL_IS_EMPTY_TEST_1