Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / preprocessor / test / vaopt.cxx
1 # /* **************************************************************************
2 #  *                                                                          *
3 #  *     (C) Copyright Edward Diener 2019.
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 <libs/preprocessor/test/test.h>
13 # include <boost/preprocessor/variadic/has_opt.hpp>
14
15 # if BOOST_PP_VARIADIC_HAS_OPT()
16
17 # include <boost/preprocessor/facilities/empty.hpp>
18 # include <boost/preprocessor/facilities/va_opt.hpp>
19 # include <boost/preprocessor/variadic/elem.hpp>
20
21 #define DATA
22 #define OBJECT OBJECT2
23 #define OBJECT2
24 #define FUNC(x) FUNC2(x)
25 #define FUNC2(x)
26 #define FUNC_GEN() ()
27 #define FUNC_GEN2(x) ()
28 #define FUNC_GEN3() (&)
29 #define FUNC_GEN4(x) (y)
30 #define FUNC_GEN5() (y,z)
31 #define FUNC_GEN6() anything
32 #define FUNC_GEN7(x) anything
33 #define FUNC_GEN8(x,y) (1,2,3)
34 #define FUNC_GEN9(x,y,z) anything
35 #define FUNC_GEN10(x) (y) data
36 #define NAME &name
37 #define ATUPLE (atuple)
38 #define ATUPLE_PLUS (atuple) data
39
40 #define TRY_PASS_EMPTY_STD(...) BOOST_PP_VARIADIC_ELEM(0, __VA_OPT__ (0,) 1)
41 #define TRY_PASS_EMPTY_BOOST(...) BOOST_PP_VARIADIC_ELEM(0,BOOST_PP_VA_OPT((0),(1),__VA_ARGS__))
42
43 BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN) == 0 END
44 BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN) == 0 END
45 BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN2) == 0 END
46 BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN2) == 0 END
47 BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN3) == 0 END
48 BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN3) == 0 END
49 BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN4) == 0 END
50 BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN4) == 0 END
51 BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN5) == 0 END
52 BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN5) == 0 END
53 BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN8) == 0 END
54 BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN8) == 0 END
55 BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN9) == 0 END
56 BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN9) == 0 END
57 BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN10) == 0 END
58 BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN10) == 0 END
59 BEGIN TRY_PASS_EMPTY_STD(BOOST_PP_EMPTY()) == 1 END
60 BEGIN TRY_PASS_EMPTY_BOOST(BOOST_PP_EMPTY()) == 1 END
61 BEGIN TRY_PASS_EMPTY_STD(DATA BOOST_PP_EMPTY()) == 1 END
62 BEGIN TRY_PASS_EMPTY_BOOST(DATA BOOST_PP_EMPTY()) == 1 END
63 BEGIN TRY_PASS_EMPTY_STD() == 1 END
64 BEGIN TRY_PASS_EMPTY_BOOST() == 1 END
65 BEGIN TRY_PASS_EMPTY_STD(DATA) == 1 END
66 BEGIN TRY_PASS_EMPTY_BOOST(DATA) == 1 END
67 BEGIN TRY_PASS_EMPTY_STD(x BOOST_PP_EMPTY()) == 0 END
68 BEGIN TRY_PASS_EMPTY_BOOST(x BOOST_PP_EMPTY()) == 0 END
69 BEGIN TRY_PASS_EMPTY_STD(OBJECT BOOST_PP_EMPTY()) == 1 END
70 BEGIN TRY_PASS_EMPTY_BOOST(OBJECT BOOST_PP_EMPTY()) == 1 END
71 BEGIN TRY_PASS_EMPTY_STD(FUNC(z) BOOST_PP_EMPTY()) == 1 END
72 BEGIN TRY_PASS_EMPTY_BOOST(FUNC(z) BOOST_PP_EMPTY()) == 1 END
73 BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN6) == 0 END
74 BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN6) == 0 END
75 BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN7) == 0 END
76 BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN7) == 0 END
77 BEGIN TRY_PASS_EMPTY_STD(NAME) == 0 END
78 BEGIN TRY_PASS_EMPTY_BOOST(NAME) == 0 END
79 BEGIN TRY_PASS_EMPTY_STD(ATUPLE) == 0 END
80 BEGIN TRY_PASS_EMPTY_BOOST(ATUPLE) == 0 END
81 BEGIN TRY_PASS_EMPTY_STD(ATUPLE_PLUS) == 0 END
82 BEGIN TRY_PASS_EMPTY_BOOST(ATUPLE_PLUS) == 0 END
83
84 # else
85
86 BEGIN 1 == 1 END
87
88 # endif