X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Ftest.cc;h=02b567237b01dd20f9d4251686172872689af442;hb=8a9b2db6f7a51d6bb1fb4bf6f37db33599cfd0fc;hp=9261ce43ba0e0515fa4e57dd3e29fc5ce28eb7f3;hpb=8e4f083438e2a6234da96f63fcceadafd5a8bd03;p=dcpomatic.git diff --git a/test/test.cc b/test/test.cc index 9261ce43b..02b567237 100644 --- a/test/test.cc +++ b/test/test.cc @@ -836,13 +836,9 @@ dcp_file (shared_ptr film, string prefix) boost::filesystem::path subtitle_file (shared_ptr film) { - for (auto i: boost::filesystem::directory_iterator(film->directory().get() / film->dcp_name (false))) { - if (boost::filesystem::is_directory(i.path())) { - for (auto j: boost::filesystem::directory_iterator(i.path())) { - if (boost::algorithm::starts_with(j.path().leaf().string(), "sub_")) { - return j.path(); - } - } + for (auto i: boost::filesystem::recursive_directory_iterator(film->directory().get() / film->dcp_name(false))) { + if (boost::algorithm::starts_with(i.path().leaf().string(), "sub_")) { + return i.path(); } } @@ -984,3 +980,27 @@ find_file (boost::filesystem::path dir, string filename_part) BOOST_REQUIRE (found); return *found; } + + +Editor::Editor(boost::filesystem::path path) + : _path(path) + , _content(dcp::file_to_string(path)) +{ + +} + +Editor::~Editor() +{ + auto f = fopen(_path.string().c_str(), "w"); + BOOST_REQUIRE(f); + fwrite(_content.c_str(), _content.length(), 1, f); + fclose(f); +} + +void +Editor::replace(string a, string b) +{ + auto old_content = _content; + boost::algorithm::replace_all(_content, a, b); + BOOST_REQUIRE(_content != old_content); +}