test_assert_is_empty.cxx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/assert_is_empty.hpp>
  6. #include <boost/preprocessor/facilities/empty.hpp>
  7. #include <boost/detail/lightweight_test.hpp>
  8. int main()
  9. {
  10. #if BOOST_PP_VARIADICS
  11. #define DATA
  12. #define OBJECT OBJECT2
  13. #define OBJECT2
  14. #define FUNC(x) FUNC2(x)
  15. #define FUNC2(x)
  16. BOOST_VMD_ASSERT_IS_EMPTY(BOOST_PP_EMPTY())
  17. BOOST_VMD_ASSERT_IS_EMPTY(DATA BOOST_PP_EMPTY())
  18. BOOST_VMD_ASSERT_IS_EMPTY(OBJECT BOOST_PP_EMPTY())
  19. BOOST_VMD_ASSERT_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY())
  20. #if BOOST_VMD_MSVC
  21. #define FUNC_GEN() ()
  22. #define FUNC_GEN2(x) ()
  23. #define FUNC_GEN3(x,y) ()
  24. /* This shows that VC++ does not work correctly in these cases. */
  25. BOOST_VMD_ASSERT_IS_EMPTY(FUNC_GEN) /* This incorrectly does not assert */
  26. BOOST_VMD_ASSERT_IS_EMPTY(FUNC_GEN2) /* This incorrectly does not assert */
  27. BOOST_VMD_ASSERT_IS_EMPTY(FUNC_GEN3) /* This should produce a compiler error but does not and does not assert */
  28. #endif /* BOOST_VMD_MSVC */
  29. #else
  30. BOOST_VMD_ASSERT(0)
  31. #endif /* BOOST_PP_VARIADICS */
  32. return boost::report_errors();
  33. }