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/is_empty.hpp>
8 #include <boost/vmd/to_seq.hpp>
9 #include <boost/vmd/is_tuple.hpp>
10 #include <boost/vmd/equal.hpp>
11 #include <boost/detail/lightweight_test.hpp>
12 #include <boost/preprocessor/list/at.hpp>
13 #include <boost/preprocessor/seq/elem.hpp>
14 #include <boost/preprocessor/tuple/elem.hpp>
15
main()16 int main()
17 {
18
19 #if BOOST_PP_VARIADICS
20
21 #define BOOST_VMD_REGISTER_ggh (ggh)
22 #define BOOST_VMD_DETECT_ggh_ggh
23 #define BOOST_VMD_REGISTER_dvd (dvd)
24 #define BOOST_VMD_DETECT_dvd_dvd
25
26 #define ANIDENTIFIER ggh
27 #define ANIDENTIFIER2 dvd
28 #define ANUMBER 249
29 #define ANUMBER2 17
30 #define ASEQ (25)(26)(27)
31 #define ATUPLE (0,1,2,3,((a,b))((c,d))((e))((f,g,h)))
32 #define ALIST (0,(1,(2,(3,BOOST_PP_NIL))))
33 #define ANARRAY (3,(a,b,38))
34 #define ASEQUENCE ANUMBER ALIST ATUPLE ANIDENTIFIER ANARRAY ASEQ
35 #define ASEQUENCE2 ANIDENTIFIER2 ASEQ ALIST ANUMBER ATUPLE
36 #define ASEQUENCE3 ASEQ ANUMBER2 ATUPLE
37 #define ASEQUENCE4
38
39 /* TO_SEQ */
40
41 BOOST_TEST(BOOST_VMD_EQUAL(BOOST_PP_TUPLE_ELEM(0,BOOST_PP_SEQ_ELEM(1,BOOST_VMD_TO_SEQ(ASEQUENCE3,BOOST_VMD_RETURN_TYPE))),BOOST_VMD_TYPE_NUMBER,BOOST_VMD_TYPE_TYPE));
42 BOOST_TEST(BOOST_VMD_IS_TUPLE(BOOST_PP_TUPLE_ELEM(1,BOOST_PP_SEQ_ELEM(4,BOOST_VMD_TO_SEQ(ASEQUENCE2,BOOST_VMD_RETURN_TYPE)))));
43 BOOST_TEST_EQ(BOOST_PP_LIST_AT(BOOST_PP_TUPLE_ELEM(1,BOOST_PP_SEQ_ELEM(1,BOOST_VMD_TO_SEQ(ASEQUENCE,BOOST_VMD_RETURN_TYPE))),3),3);
44 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_TO_SEQ(ASEQUENCE4,BOOST_VMD_RETURN_TYPE)));
45
46 /* TO_SEQ_DATA */
47
48 BOOST_TEST_EQ(BOOST_PP_SEQ_ELEM(1,BOOST_PP_SEQ_ELEM(1,BOOST_VMD_TO_SEQ(ASEQUENCE2))),26);
49 BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_VMD_TO_SEQ(ASEQUENCE4)));
50 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(1,BOOST_PP_SEQ_ELEM(2,BOOST_VMD_TO_SEQ(ASEQUENCE))),1);
51 BOOST_TEST_EQ(BOOST_PP_SEQ_ELEM(1,BOOST_VMD_TO_SEQ(ASEQUENCE3)),17);
52
53 #else
54
55 BOOST_ERROR("No variadic macro support");
56
57 #endif
58
59 return boost::report_errors();
60
61 }
62