Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / vmd / test / test_assert.cxx
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/assert.hpp>
9 #include <boost/vmd/is_identifier.hpp>
10 #include <boost/vmd/is_empty.hpp>
11 #include <boost/vmd/is_number.hpp>
12 #include <boost/vmd/is_type.hpp>
13 #include <boost/detail/lightweight_test.hpp>
14 #include <boost/preprocessor/arithmetic/dec.hpp>
15 #include <boost/preprocessor/arithmetic/inc.hpp>
16 #include <boost/preprocessor/comparison/equal.hpp>
17 #include <boost/preprocessor/facilities/empty.hpp>
18 #include <boost/preprocessor/list/at.hpp>
19 #include <boost/preprocessor/logical/compl.hpp>
20 #include <boost/preprocessor/seq/elem.hpp>
21 #include <boost/preprocessor/tuple/elem.hpp>
22
23 int main()
24   {
25   
26 #if BOOST_PP_VARIADICS
27
28   #define A_PTUPLE (*,#,44)
29   #define AN_ARRAY_PLUS (4,(mmf,34,^^,!)) 156
30   #define A_TUPLE (*,#,zzz ())
31   #define DATA
32   #define JDATA somevalue
33   #define KDATA (a,b) name
34   #define A_LIST (eeb,(grist,(152,BOOST_PP_NIL)))
35   #define A_LIST_PLUS (mmf,(34,(^^,(!,BOOST_PP_NIL)))) 56
36   #define A_SEQ (73 (split) clear)(red)(green 44)
37   #define A_SEQ2 (73 (split) clear)(BOOST_VMD_TYPE_LIST)(green 44)
38   #define A_SEQ_PLUS (mmf)(34)(^^)(!) 456
39   
40   #define BOOST_VMD_REGISTER_zzz (zzz)
41   #define BOOST_VMD_DETECT_zzz_zzz
42   #define BOOST_VMD_REGISTER_somevalue (somevalue)
43   #define BOOST_VMD_DETECT_somevalue_somevalue
44   
45   BOOST_VMD_ASSERT(25)
46   BOOST_VMD_ASSERT(BOOST_PP_DEC(2))
47   BOOST_VMD_ASSERT(BOOST_PP_INC(255))
48   BOOST_VMD_ASSERT
49       (
50       BOOST_PP_EQUAL
51           (
52           BOOST_PP_TUPLE_ELEM(2,A_PTUPLE),
53           44
54           )
55       )
56       
57   BOOST_VMD_ASSERT(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(0,AN_ARRAY_PLUS,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_ARRAY)),156))
58   BOOST_VMD_ASSERT
59       (
60       BOOST_PP_EQUAL
61           (
62         BOOST_PP_TUPLE_ELEM
63             (
64             2,
65             BOOST_VMD_ELEM(0,BOOST_PP_TUPLE_ELEM(2,A_TUPLE),(dummy1,zzz),BOOST_VMD_RETURN_AFTER,BOOST_VMD_RETURN_INDEX,BOOST_VMD_TYPE_IDENTIFIER)
66             ),
67         1
68           )
69       )
70       
71   BOOST_VMD_ASSERT(BOOST_VMD_IS_EMPTY(DATA BOOST_PP_EMPTY()))
72   BOOST_VMD_ASSERT(BOOST_VMD_IS_IDENTIFIER(JDATA,somevalue))
73   BOOST_VMD_ASSERT(BOOST_VMD_IS_NUMBER(BOOST_PP_LIST_AT(A_LIST,2)))
74   BOOST_VMD_ASSERT(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(0,A_LIST_PLUS,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_LIST)),56))
75   BOOST_VMD_ASSERT(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(0,BOOST_PP_SEQ_ELEM(0,A_SEQ),BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_NUMBER)),73))
76   BOOST_VMD_ASSERT(BOOST_PP_EQUAL(BOOST_PP_SEQ_ELEM(1,BOOST_PP_TUPLE_ELEM(0,BOOST_VMD_ELEM(0,A_SEQ_PLUS,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_SEQ))),34))
77   BOOST_VMD_ASSERT(BOOST_PP_COMPL(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_ELEM(0,KDATA,BOOST_VMD_RETURN_AFTER,BOOST_VMD_TYPE_TUPLE)))))
78   
79   BOOST_VMD_ASSERT(BOOST_VMD_IS_TYPE(BOOST_PP_SEQ_ELEM(1,A_SEQ2)))
80   
81 #else
82
83   BOOST_VMD_ASSERT(0)
84   
85 #endif
86
87   return boost::report_errors();
88   
89   }