From: Carl Hetherington Date: Sun, 25 Sep 2022 23:02:17 +0000 (+0200) Subject: Move Editor class to test.{cc,h} X-Git-Tag: v2.16.28~4 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=dea555a6d395e74c20436123a5f3b5bd623ebcf6 Move Editor class to test.{cc,h} --- diff --git a/test/subtitle_font_id_change_test.cc b/test/subtitle_font_id_change_test.cc index f32541980..878dc6506 100644 --- a/test/subtitle_font_id_change_test.cc +++ b/test/subtitle_font_id_change_test.cc @@ -38,37 +38,6 @@ using std::string; -class Editor -{ -public: - Editor (boost::filesystem::path path) - : _path(path) - , _content(dcp::file_to_string(path)) - { - - } - - ~Editor () - { - auto f = fopen(_path.string().c_str(), "w"); - BOOST_REQUIRE(f); - fwrite(_content.c_str(), _content.length(), 1, f); - fclose(f); - } - - void replace (string a, string b) - { - auto old_content = _content; - boost::algorithm::replace_all (_content, a, b); - BOOST_REQUIRE (_content != old_content); - } - -private: - boost::filesystem::path _path; - std::string _content; -}; - - BOOST_AUTO_TEST_CASE(subtitle_font_id_change_test1) { auto film = new_test_film2("subtitle_font_id_change_test1"); diff --git a/test/test.cc b/test/test.cc index f1fd40fb7..02b567237 100644 --- a/test/test.cc +++ b/test/test.cc @@ -980,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); +} diff --git a/test/test.h b/test/test.h index 10113b662..8bcef0604 100644 --- a/test/test.h +++ b/test/test.h @@ -97,6 +97,20 @@ public: }; +class Editor +{ +public: + Editor(boost::filesystem::path path); + ~Editor(); + + void replace(std::string a, std::string b); + +private: + boost::filesystem::path _path; + std::string _content; +}; + + namespace dcp { std::ostream& operator<< (std::ostream& s, dcp::Size i);