boost_test_macro_workaround.run.cpp 875 B

123456789101112131415161718192021222324252627282930
  1. // (C) Copyright Raffi Enficiaud 2014.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //[example_code
  7. #define BOOST_TEST_MODULE boost_test_macro_workaround
  8. #include <boost/test/included/unit_test.hpp>
  9. #include <sstream>
  10. BOOST_AUTO_TEST_CASE( test_logical_not_allowed )
  11. {
  12. // Boost Unit Test Framework prevents compilation of
  13. // BOOST_TEST(true && true);
  14. BOOST_TEST((true && true)); // with extra brackets, it works as expected
  15. }
  16. BOOST_AUTO_TEST_CASE( test_ternary )
  17. {
  18. int a = 1;
  19. int b = 2;
  20. // Boost Unit Test Framework prevents compilation of
  21. // BOOST_TEST(a == b ? true : false);
  22. BOOST_TEST((a + 1 == b ? true : false)); // again works as expected with extra brackets
  23. }
  24. //]