sample_test.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // filesystem sample_test.cpp ----------------------------------------------//
  2. // Copyright Beman Dawes 2012
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // See http://www.boost.org/LICENSE_1_0.txt
  5. // --------------------------------------------------------------------------//
  6. //
  7. // This program provides a template for bug reporting test cases.
  8. //
  9. // --------------------------------------------------------------------------//
  10. #include <boost/config/warning_disable.hpp>
  11. #include <boost/filesystem.hpp>
  12. #include <boost/detail/lightweight_test.hpp>
  13. #include <iostream>
  14. #include <string>
  15. #include <cstring>
  16. #ifndef BOOST_LIGHTWEIGHT_MAIN
  17. # include <boost/test/prg_exec_monitor.hpp>
  18. #else
  19. # include <boost/detail/lightweight_main.hpp>
  20. #endif
  21. namespace fs = boost::filesystem;
  22. using fs::path;
  23. using std::cout;
  24. using std::endl;
  25. using std::string;
  26. using std::wstring;
  27. namespace
  28. {
  29. bool cleanup = true;
  30. }
  31. // cpp_main ----------------------------------------------------------------//
  32. int cpp_main(int argc, char* argv[])
  33. {
  34. if (argc > 1 && std::strcmp(argv[1], "--no-cleanup") == 0)
  35. cleanup = false;
  36. // Test cases go after this block of comments
  37. // Use test case macros from boost/detail/lightweight_test.hpp:
  38. //
  39. // BOOST_TEST(predicate); // test passes if predicate evaluates to true
  40. // BOOST_TEST_EQ(x, y); // test passes if x == y
  41. // BOOST_TEST_NE(x, y); // test passes if x != y
  42. // BOOST_ERROR(msg); // test fails, outputs msg
  43. // Examples:
  44. // BOOST_TEST(path("f00").size() == 3); // test passes
  45. // BOOST_TEST_EQ(path("f00").size(), 3); // test passes
  46. // BOOST_MSG("Oops!"); // test fails, outputs "Oops!"
  47. if (cleanup)
  48. {
  49. // Remove any test files or directories here
  50. }
  51. return ::boost::report_errors();
  52. }