test_sequence_to_seq.cxx 2.1 KB

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