unit_test_example_01.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // (C) Copyright Gennadiy Rozental 2005.
  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. // Boost.Test
  7. // each test module could contain no more then one 'main' file with init function defined
  8. // alternatively you could define init function yourself
  9. #define BOOST_TEST_MAIN
  10. #include <boost/test/unit_test.hpp>
  11. namespace bt = boost::unit_test;
  12. //____________________________________________________________________________//
  13. // most frequently you implement test cases as a free functions with automatic registration
  14. BOOST_AUTO_TEST_CASE( test1 )
  15. {
  16. // reports 'error in "test1": test 2 == 1 failed'
  17. BOOST_TEST( 2 == 1 );
  18. }
  19. //____________________________________________________________________________//
  20. // each test file may contain any number of test cases; each test case has to have unique name
  21. BOOST_AUTO_TEST_CASE( test2 )
  22. {
  23. int i = 0;
  24. // reports 'error in "test2": check i == 2 failed [0 != 2]'
  25. BOOST_TEST( i == 2 );
  26. BOOST_TEST( i == 0 );
  27. }
  28. //____________________________________________________________________________//
  29. // EOF