• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 //  (C) Copyright Edward Diener 2011-2015
3 //  Use, modification and distribution are subject to the Boost Software License,
4 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 //  http://www.boost.org/LICENSE_1_0.txt).
6 
7 #include <boost/vmd/elem.hpp>
8 #include <boost/vmd/is_empty.hpp>
9 #include <boost/detail/lightweight_test.hpp>
10 #include <boost/preprocessor/list/at.hpp>
11 #include <boost/preprocessor/punctuation/is_begin_parens.hpp>
12 #include <boost/preprocessor/seq/elem.hpp>
13 #include <boost/preprocessor/tuple/elem.hpp>
14 
main()15 int main()
16   {
17 
18 #if BOOST_PP_VARIADICS
19 
20   #define BOOST_VMD_REGISTER_ggh (ggh)
21 
22   #define ANIDENTIFIER ggh
23   #define ANUMBER 249
24   #define ANUMBER2 25
25   #define ANUMBER3 158
26   #define ANUMBER5 73
27   #define ASEQ (25)(26)(27)
28   #define ATUPLE (0,1,2,3,((a,b))((c,d))((e))((f,g,h)))
29   #define ALIST (0,(1,(2,(3,BOOST_PP_NIL))))
30   #define ANARRAY (3,(a,b,38))
31   #define ANARRAY2 (5,(c,d,133,22,15))
32   #define ASEQUENCE ANUMBER ALIST ATUPLE ANIDENTIFIER ANARRAY ASEQ
33   #define ASEQUENCE2 ANIDENTIFIER ANARRAY2 ASEQ ALIST ANUMBER2 ATUPLE
34   #define ASEQUENCE3 ASEQ ANUMBER3 ANIDENTIFIER ATUPLE
35   #define ASEQUENCE4
36   #define ASEQUENCE5 ASEQ ANUMBER5 ATUPLE ANIDENTIFIER
37 
38   #define A_TUPLE (27,251,145 ())
39   #define JDATA 43
40   #define A_SEQ (73 (split) clear)(red)(green 44)
41   #define A_LIST (17 (5),(grist,(yellow,BOOST_PP_NIL)))
42 
43   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,ASEQUENCE,BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
44   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(4,ASEQUENCE2,BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
45   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(1,ASEQUENCE3,BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
46   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,ASEQUENCE4,BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
47   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(1,ASEQUENCE5,BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
48 
49   BOOST_TEST(BOOST_PP_IS_BEGIN_PARENS(BOOST_VMD_ELEM(0,BOOST_PP_TUPLE_ELEM(2,A_TUPLE),BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
50   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,JDATA,BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
51   BOOST_TEST(BOOST_PP_IS_BEGIN_PARENS(BOOST_VMD_ELEM(0,BOOST_PP_SEQ_ELEM(0,A_SEQ),BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
52   BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(0,BOOST_PP_LIST_AT(A_LIST,0),BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)),5);
53   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,BOOST_PP_LIST_AT(A_LIST,1),BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
54   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,BOOST_PP_SEQ_ELEM(2,A_SEQ),BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
55 
56   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,253 num,BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
57   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,17 181 201 somevalue num,BOOST_VMD_RETURN_ONLY_AFTER,BOOST_VMD_TYPE_NUMBER)));
58 
59 #else
60 
61 BOOST_ERROR("No variadic macro support");
62 
63 #endif
64 
65   return boost::report_errors();
66 
67   }
68