Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / preprocessor / test / isempty.cxx
1 # /* **************************************************************************
2 #  *                                                                          *
3 #  *     (C) Copyright Edward Diener 2014.
4 #  *     Distributed under the Boost Software License, Version 1.0. (See
5 #  *     accompanying file LICENSE_1_0.txt or copy at
6 #  *     http://www.boost.org/LICENSE_1_0.txt)
7 #  *                                                                          *
8 #  ************************************************************************** */
9 #
10 # /* See http://www.boost.org for most recent version. */
11 #
12 # include <boost/preprocessor/config/config.hpp>
13 #
14 #if (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()) || (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC())
15
16 # include <boost/preprocessor/facilities/empty.hpp>
17 # include <boost/preprocessor/facilities/is_empty.hpp>
18 # include <libs/preprocessor/test/test.h>
19
20 #define DATA
21 #define OBJECT OBJECT2
22 #define OBJECT2
23 #define FUNC(x) FUNC2(x)
24 #define FUNC2(x)
25 #define FUNC_GEN() ()
26 #define FUNC_GEN2(x) ()
27 #define FUNC_GEN3() (&)
28 #define FUNC_GEN4(x) (y)
29 #define FUNC_GEN5() (y,z)
30 #define FUNC_GEN6() anything
31 #define FUNC_GEN7(x) anything
32 #define FUNC_GEN8(x,y) (1,2,3)
33 #define FUNC_GEN9(x,y,z) anything
34 #define FUNC_GEN10(x) (y) data
35 #define NAME &name
36 #define ATUPLE (atuple)
37 #define ATUPLE_PLUS (atuple) data
38
39 #if BOOST_PP_VARIADICS
40
41 # include <boost/preprocessor/variadic/has_opt.hpp>
42
43 #if defined(__cplusplus) && __cplusplus > 201703L && BOOST_PP_VARIADIC_HAS_OPT()
44
45 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 0 END
46 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 0 END
47 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END
48 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END
49 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END
50 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END
51 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
52 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END
53
54 #elif BOOST_PP_VARIADICS_MSVC /* Testing the VC++ variadic version */
55
56 /* INCORRECT */
57
58 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 1 END
59 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 1 END
60 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 1 END
61 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 1 END
62 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 1 END
63 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 1 END
64 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 1 END
65
66 /* CORRECT */
67
68 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
69
70 #else /* Testing the non-VC++ variadic version */
71
72 /* CORRECT */
73
74 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 0 END
75 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 0 END
76 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END
77 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END
78 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END
79 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END
80
81 /* COMPILER ERROR */
82
83 // BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END
84 // BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
85
86 #endif
87
88 /* Testing the variadic version */
89
90 /* CORRECT */
91
92 BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY()) == 1 END
93 BEGIN BOOST_PP_IS_EMPTY(DATA BOOST_PP_EMPTY()) == 1 END
94 BEGIN BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()) == 0 END
95 BEGIN BOOST_PP_IS_EMPTY(OBJECT BOOST_PP_EMPTY()) == 1 END
96 BEGIN BOOST_PP_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY()) == 1 END
97 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN6) == 0 END
98 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN7) == 0 END
99 BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END
100 BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 0 END
101 BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 0 END
102
103 #else
104
105 #if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() /* Testing the VC++ non-variadic version */
106
107 /* INCORRECT */
108
109 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 1 END
110 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 1 END
111 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 1 END
112 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 1 END
113 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 1 END
114 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 1 END
115 BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 1 END
116 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 1 END
117 BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 1 END
118
119 /* CORRECT */
120
121 BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END
122
123 #else /* Testing the non-VC++ non-variadic version */
124
125 /* CORRECT */
126
127 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 0 END
128 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 0 END
129 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END
130 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END
131 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END
132 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END
133 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END
134
135 /* UNDEFINED BEHAVIOR */
136
137 // BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 0 END
138 // BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 1 END
139 // BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END
140
141 #endif
142
143 /* Testing the non-variadic version */
144
145 /* CORRECT */
146
147 BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY()) == 1 END
148 BEGIN BOOST_PP_IS_EMPTY(DATA BOOST_PP_EMPTY()) == 1 END
149 BEGIN BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()) == 0 END
150 BEGIN BOOST_PP_IS_EMPTY(OBJECT BOOST_PP_EMPTY()) == 1 END
151 BEGIN BOOST_PP_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY()) == 1 END
152 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN6) == 0 END
153 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN7) == 0 END
154 BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
155
156 #endif
157
158 #endif