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/seq/elem.hpp>
11 #include <boost/preprocessor/tuple/elem.hpp>
12
main()13 int main()
14 {
15
16 #if BOOST_PP_VARIADICS
17
18 #define BOOST_VMD_REGISTER_ggh (ggh)
19
20 #define ANIDENTIFIER ggh
21 #define ANUMBER 249
22 #define ASEQ (25)(26)(27)
23 #define ASEQ2 (75)(76)(77)
24 #define ASEQ3 (147)(148)(149)
25 #define ASEQ5 (221)(222)(223)
26 #define ATUPLE (0,1,2,3,((a,b))((c,d))((e))((f,g,h)))
27 #define ALIST (0,(1,(2,(3,BOOST_PP_NIL))))
28 #define ANARRAY (3,(a,b,38))
29 #define ANARRAY2 (5,(c,d,133,22,15))
30 #define ASEQUENCE ANUMBER ALIST ATUPLE ANIDENTIFIER ANARRAY ASEQ
31 #define ASEQUENCE2 ANIDENTIFIER ANARRAY2 ALIST ASEQ2 ATUPLE
32 #define ASEQUENCE3 ASEQ3 ANIDENTIFIER ATUPLE ALIST
33 #define ASEQUENCE4
34 #define ASEQUENCE5 ALIST ASEQ5 ATUPLE ANIDENTIFIER
35
36 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(0,ASEQUENCE,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))));
37 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(0,ASEQUENCE2,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))));
38 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(0,ASEQUENCE5,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))));
39
40 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(5,ASEQUENCE,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))));
41 BOOST_TEST_EQ(BOOST_PP_SEQ_ELEM(2,BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(5,ASEQUENCE,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))),27);
42 BOOST_TEST_EQ(BOOST_PP_SEQ_ELEM(0,BOOST_VMD_ELEM(5,ASEQUENCE,BOOST_VMD_TYPE_SEQ)),25);
43
44 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(3,BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(3,ASEQUENCE2,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))),3);
45 BOOST_TEST_EQ(BOOST_PP_SEQ_ELEM(1,BOOST_VMD_ELEM(3,ASEQUENCE2,BOOST_VMD_TYPE_SEQ)),76);
46
47 BOOST_TEST_EQ(BOOST_PP_SEQ_ELEM(2,BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(0,ASEQUENCE3,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))),149);
48 BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(0,ASEQUENCE3,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))));
49 BOOST_TEST_EQ(BOOST_PP_SEQ_ELEM(0,BOOST_VMD_ELEM(0,ASEQUENCE3,BOOST_VMD_TYPE_SEQ)),147);
50
51 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(0,ASEQUENCE4,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))));
52 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(0,ASEQUENCE4,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))));
53 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,ASEQUENCE4,BOOST_VMD_TYPE_SEQ)));
54
55 BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(1,ASEQUENCE5,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))));
56 BOOST_TEST_EQ(BOOST_PP_SEQ_ELEM(2,BOOST_VMD_ELEM(1,ASEQUENCE5,BOOST_VMD_TYPE_SEQ)),223);
57
58 #else
59
60 BOOST_ERROR("No variadic macro support");
61
62 #endif
63
64 return boost::report_errors();
65
66 }
67