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