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/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 ATUPLE (0,1,2,3,((a,b))((c,d))((e))((f,g,h)))
24 #define ATUPLE2 (10,11,12,13)
25 #define ATUPLE3 (100,101,102,103)
26 #define ATUPLE5 (200,201,202,203)
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 ASEQ ATUPLE2
32 #define ASEQUENCE3 ASEQ ANIDENTIFIER ATUPLE3 ALIST
33 #define ASEQUENCE4
34 #define ASEQUENCE5 ALIST ASEQ ATUPLE5 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_TUPLE))));
37 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(0,ASEQUENCE2,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_TUPLE))));
38 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(0,ASEQUENCE3,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_TUPLE))));
39
40 BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(2,ASEQUENCE,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_TUPLE))));
41 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(2,BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(2,ASEQUENCE,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_TUPLE))),2);
42 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(3,BOOST_VMD_ELEM(2,ASEQUENCE,BOOST_VMD_TYPE_TUPLE)),3);
43
44 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(4,ASEQUENCE2,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_TUPLE))));
45 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(4,ASEQUENCE2,BOOST_VMD_TYPE_TUPLE)),11);
46
47 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(2,BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(2,ASEQUENCE3,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_TUPLE))),102);
48 BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(2,ASEQUENCE3,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_TUPLE))));
49 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(2,ASEQUENCE3,BOOST_VMD_TYPE_TUPLE)),100);
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_TUPLE))));
52 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(0,ASEQUENCE4,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_TUPLE))));
53 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_ELEM(0,ASEQUENCE4,BOOST_VMD_TYPE_TUPLE)));
54
55 BOOST_TEST(!BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(2,ASEQUENCE5,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_TUPLE))));
56 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(2,BOOST_VMD_ELEM(2,ASEQUENCE5,BOOST_VMD_TYPE_TUPLE)),202);
57
58 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(3,BOOST_VMD_ELEM(2,ASEQUENCE,BOOST_VMD_TYPE_TUPLE)),3);
59
60 #else
61
62 BOOST_ERROR("No variadic macro support");
63
64 #endif
65
66 return boost::report_errors();
67
68 }
69