test_assert.cxx 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // (C) Copyright Edward Diener 2011-2015
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. #include <boost/vmd/elem.hpp>
  6. #include <boost/vmd/assert.hpp>
  7. #include <boost/vmd/is_identifier.hpp>
  8. #include <boost/vmd/is_empty.hpp>
  9. #include <boost/vmd/is_number.hpp>
  10. #include <boost/vmd/is_type.hpp>
  11. #include <boost/detail/lightweight_test.hpp>
  12. #include <boost/preprocessor/arithmetic/dec.hpp>
  13. #include <boost/preprocessor/arithmetic/inc.hpp>
  14. #include <boost/preprocessor/comparison/equal.hpp>
  15. #include <boost/preprocessor/facilities/empty.hpp>
  16. #include <boost/preprocessor/list/at.hpp>
  17. #include <boost/preprocessor/logical/compl.hpp>
  18. #include <boost/preprocessor/seq/elem.hpp>
  19. #include <boost/preprocessor/tuple/elem.hpp>
  20. int main()
  21. {
  22. #if BOOST_PP_VARIADICS
  23. #define A_PTUPLE (*,#,44)
  24. #define AN_ARRAY_PLUS (4,(mmf,34,^^,!)) 156
  25. #define A_TUPLE (*,#,zzz ())
  26. #define DATA
  27. #define JDATA somevalue
  28. #define KDATA (a,b) name
  29. #define A_LIST (eeb,(grist,(152,BOOST_PP_NIL)))
  30. #define A_LIST_PLUS (mmf,(34,(^^,(!,BOOST_PP_NIL)))) 56
  31. #define A_SEQ (73 (split) clear)(red)(green 44)
  32. #define A_SEQ2 (73 (split) clear)(BOOST_VMD_TYPE_LIST)(green 44)
  33. #define A_SEQ_PLUS (mmf)(34)(^^)(!) 456
  34. #define BOOST_VMD_REGISTER_zzz (zzz)
  35. #define BOOST_VMD_DETECT_zzz_zzz
  36. #define BOOST_VMD_REGISTER_somevalue (somevalue)
  37. #define BOOST_VMD_DETECT_somevalue_somevalue
  38. BOOST_VMD_ASSERT(25)
  39. BOOST_VMD_ASSERT(BOOST_PP_DEC(2))
  40. BOOST_VMD_ASSERT(BOOST_PP_INC(255))
  41. BOOST_VMD_ASSERT
  42. (
  43. BOOST_PP_EQUAL
  44. (
  45. BOOST_PP_TUPLE_ELEM(2,A_PTUPLE),
  46. 44
  47. )
  48. )
  49. 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))
  50. BOOST_VMD_ASSERT
  51. (
  52. BOOST_PP_EQUAL
  53. (
  54. BOOST_PP_TUPLE_ELEM
  55. (
  56. 2,
  57. 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)
  58. ),
  59. 1
  60. )
  61. )
  62. BOOST_VMD_ASSERT(BOOST_VMD_IS_EMPTY(DATA BOOST_PP_EMPTY()))
  63. BOOST_VMD_ASSERT(BOOST_VMD_IS_IDENTIFIER(JDATA,somevalue))
  64. BOOST_VMD_ASSERT(BOOST_VMD_IS_NUMBER(BOOST_PP_LIST_AT(A_LIST,2)))
  65. 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))
  66. 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))
  67. 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))
  68. 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)))))
  69. BOOST_VMD_ASSERT(BOOST_VMD_IS_TYPE(BOOST_PP_SEQ_ELEM(1,A_SEQ2)))
  70. #else
  71. BOOST_VMD_ASSERT(0)
  72. #endif
  73. return boost::report_errors();
  74. }