• 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/tuple/elem.hpp>
11 
main()12 int main()
13   {
14 
15 #if BOOST_PP_VARIADICS
16 
17   #define BOOST_VMD_REGISTER_ggh (ggh)
18   #define BOOST_VMD_REGISTER_dvd (dvd)
19   #define BOOST_VMD_REGISTER_ccc (ccc)
20   #define BOOST_VMD_REGISTER_aname (aname)
21 
22   #define BOOST_VMD_DETECT_ggh_ggh
23   #define BOOST_VMD_DETECT_ccc_ccc
24   #define BOOST_VMD_DETECT_aname_aname
25 
26   #define ANIDENTIFIER ggh
27   #define ANIDENTIFIER2 dvd
28   #define ANIDENTIFIER3 ccc
29   #define ANIDENTIFIER5 aname
30   #define ANUMBER 249
31   #define ANUMBER2 17
32   #define ASEQ (25)(26)(27)
33   #define ATUPLE (0,1,2,3,((a,b))((c,d))((e))((f,g,h)))
34   #define ALIST (0,(1,(2,(3,BOOST_PP_NIL))))
35   #define ANARRAY (3,(a,b,38))
36   #define ANARRAY2 (5,(c,d,133,22,15))
37   #define ANARRAY3 (5,(ccc,dvd,133,22,15))
38   #define ASEQUENCE ANUMBER ALIST ATUPLE ANIDENTIFIER ANARRAY ASEQ
39   #define ASEQUENCE2 ANIDENTIFIER2 ANARRAY2 ASEQ ALIST ANUMBER ATUPLE
40   #define ASEQUENCE3 ASEQ ANUMBER2 ANIDENTIFIER3 ATUPLE
41   #define ASEQUENCE4
42   #define ASEQUENCE5 ASEQ ANUMBER ATUPLE ANIDENTIFIER5
43 
44   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(0,ANARRAY,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))));
45   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,ALIST,BOOST_VMD_TYPE_IDENTIFIER)));
46   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(0,ASEQ,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))));
47 
48   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,ANIDENTIFIER3,(ggh,dvd,ccc),BOOST_VMD_TYPE_IDENTIFIER)));
49 
50   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(3,ASEQUENCE,(dvd,ccc,ggh),BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))));
51   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(3,ASEQUENCE,ccc,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))));
52   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(3,ASEQUENCE,(ccc,ggh),BOOST_VMD_TYPE_IDENTIFIER)));
53 
54   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(0,ASEQUENCE2,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))));
55   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,ASEQUENCE2,BOOST_VMD_TYPE_IDENTIFIER)));
56 
57   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(2,ASEQUENCE3,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))));
58   BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(3,BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(2,ASEQUENCE3,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))),3);
59   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(2,ASEQUENCE3,BOOST_VMD_TYPE_IDENTIFIER)));
60 
61   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(0,ASEQUENCE4,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))));
62   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(0,ASEQUENCE4,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))));
63   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,ASEQUENCE4,BOOST_VMD_TYPE_IDENTIFIER)));
64 
65   BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(3,ASEQUENCE5,aname,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))));
66   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(3,ASEQUENCE5,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))));
67   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(3,ASEQUENCE5,(ccc,dvd),BOOST_VMD_TYPE_IDENTIFIER)));
68 
69   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(4,ASEQUENCE5,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_IDENTIFIER))));
70   BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(4,ASEQUENCE5,BOOST_VMD_TYPE_IDENTIFIER)));
71 
72 #else
73 
74 BOOST_ERROR("No variadic macro support");
75 
76 #endif
77 
78   return boost::report_errors();
79 
80   }
81