From d08c6a1ee3e692763b54e57c95a0f38f199c03ef Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 27 May 2016 13:19:29 +0200 Subject: [PATCH] Added read/write tests to source_test --- tests/source_test.cc | 15 +++++++++++++-- tests/tmp/.keep | 0 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 tests/tmp/.keep diff --git a/tests/source_test.cc b/tests/source_test.cc index 8c1a733..2da9cb5 100644 --- a/tests/source_test.cc +++ b/tests/source_test.cc @@ -24,8 +24,19 @@ int main() { auto app=Gtk::Application::create(); Gsv::init(); - Source::View source_view("", Glib::RefPtr()); - source_view.get_buffer()->set_text(hello_world); + auto tests_path=boost::filesystem::canonical(JUCI_TESTS_PATH); + auto source_file=tests_path/"tmp"/"source_file.txt"; + + { + Source::View source_view(source_file, Glib::RefPtr()); + source_view.get_buffer()->set_text(hello_world); + g_assert(source_view.save({&source_view})); + } + + Source::View source_view(source_file, Glib::RefPtr()); source_view.cleanup_whitespace_characters(); g_assert(source_view.get_buffer()->get_text()==hello_world_cleaned); + + g_assert(boost::filesystem::remove(source_file)); + g_assert(!boost::filesystem::exists(source_file)); } diff --git a/tests/tmp/.keep b/tests/tmp/.keep new file mode 100644 index 0000000..e69de29