Move Editor class to test.{cc,h}
authorCarl Hetherington <cth@carlh.net>
Sun, 25 Sep 2022 23:02:17 +0000 (01:02 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 25 Sep 2022 23:02:17 +0000 (01:02 +0200)
test/subtitle_font_id_change_test.cc
test/test.cc
test/test.h

index f325419800b67233a5e92eb43a7abf6edda3d1ee..878dc650668bd30d152aaea709fcb1b1f873b477 100644 (file)
 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");
index f1fd40fb791597c4bf5da7e960a05b523b5878cb..02b567237b01dd20f9d4251686172872689af442 100644 (file)
@@ -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);
+}
index 10113b66276afae11a42af1a2cb442bfe05aba0c..8bcef0604c9b3a080a839735b4e034dc0bc45900 100644 (file)
@@ -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);