summaryrefslogtreecommitdiff
path: root/test/test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-09-26 01:02:17 +0200
committerCarl Hetherington <cth@carlh.net>2022-09-26 01:02:17 +0200
commitdea555a6d395e74c20436123a5f3b5bd623ebcf6 (patch)
tree4dd96f24249d8647adb9440f03704c4290a62541 /test/test.cc
parent3cd0685fb3f3222b3e9a2406986274031befeae6 (diff)
Move Editor class to test.{cc,h}
Diffstat (limited to 'test/test.cc')
-rw-r--r--test/test.cc24
1 files changed, 24 insertions, 0 deletions
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);
+}