1#define BOOST_TEST_MODULE fc_filesystem
2#include <boost/test/included/unit_test.hpp>
3#include <boost/filesystem/fstream.hpp>
11 boost::filesystem::ifstream ifs { filename };
17BOOST_AUTO_TEST_SUITE(fc_filesystem)
23 const string src_dir {
"/tmp/fc_copy_test_src"};
29 const string test_file_name =
"fc_copy_test_file";
30 if (!
fc::exists(src_dir +
"/" + test_file_name)) {
31 boost::filesystem::ofstream ofs { src_dir +
"/" + test_file_name};
32 ofs <<
"This the test of fc system copy \n";
35 BOOST_CHECK_EQUAL(
fc::exists(src_dir +
"/" + test_file_name),
true);
37 const string tgt_dir {
"/tmp/fc_copy_test_tgt"};
46 BOOST_CHECK_EQUAL(
fc::exists(tgt_dir +
"/" + test_file_name),
false);
58 const string src_dir {
"/tmp/fc_copy_test_src"};
64 const string test_file_name =
"fc_copy_test_file";
65 if (!
fc::exists(src_dir +
"/" + test_file_name)) {
66 boost::filesystem::ofstream ofs { src_dir +
"/" + test_file_name};
67 ofs <<
"This the test of fc system copy \n";
70 BOOST_CHECK_EQUAL(
fc::exists(src_dir +
"/" + test_file_name),
true);
72 const string tgt_dir {
"/tmp/fc_copy_test_tgt"};
77 BOOST_CHECK_EQUAL(
fc::exists(tgt_dir +
"/" + test_file_name),
false);
78 fc::copy(src_dir +
"/" + test_file_name, tgt_dir +
"/" + test_file_name);
79 BOOST_CHECK_EQUAL(
fc::exists(tgt_dir +
"/" + test_file_name),
true);
80 const string src_file_content =
getFileContent(src_dir +
"/" + test_file_name);
81 BOOST_CHECK_EQUAL(src_file_content.empty(),
false);
82 const string tgt_file_content =
getFileContent(tgt_dir +
"/" + test_file_name);
83 BOOST_CHECK_EQUAL(src_file_content, tgt_file_content);
86 BOOST_CHECK_EQUAL(
fc::exists(tgt_dir +
"/" + test_file_name),
true);
87 BOOST_CHECK_EXCEPTION(
fc::copy(src_dir +
"/" + test_file_name, tgt_dir +
"/" + test_file_name),
95BOOST_AUTO_TEST_SUITE_END()
Used to generate a useful error report when an exception is thrown.
Defines exception's used by fc.
bool exists(const path &p)
void remove_all(const path &p)
void create_directories(const path &p)
void copy(const path &from, const path &to)
@ unspecified_exception_code
std::string getFileContent(const string &filename)
BOOST_AUTO_TEST_CASE(dir_copy)