>From 2b08251c7af89a7feef9e90c31dbcbbeac505a4d Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Tue, 16 Dec 2014 22:28:19 +0100
Subject: [PATCH 1/5] Refactor: extract output_file_existence_checker into a
separate header.
Make this helper class available for reuse in other test cases.
No changes in the behaviour.
---
wx_test_output.hpp | 69 +++++++++++++++++++++++++++++++++++++++++++
wx_test_validate_output.cpp | 44 +--------------------------
2 files changed, 70 insertions(+), 43 deletions(-)
create mode 100644 wx_test_output.hpp
diff --git a/wx_test_output.hpp b/wx_test_output.hpp
new file mode 100644
index 0000000..4c9cc7c
--- /dev/null
+++ b/wx_test_output.hpp
@@ -0,0 +1,69 @@
+// Helpers for working with output files in wx test suite code.
+//
+// Copyright (C) 2014 Gregory W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// http://savannah.nongnu.org/projects/lmi
+// email:
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+// $Id$
+
+#ifndef wx_test_output_hpp
+#define wx_test_output_hpp
+
+#include "config.hpp"
+
+#include "uncopyable_lmi.hpp"
+
+#include
+
+/// Class helping to check for the expected output file existence.
+///
+/// This class takes care of ensuring that the file doesn't exist when it is
+/// constructed and provides a way to check for the existence of the file
+/// later. It also cleans up the file when it is destroyed.
+
+class output_file_existence_checker
+ :private lmi::uncopyable
+{
+ public:
+ output_file_existence_checker(std::string const& path)
+ :path_(path)
+ {
+ fs::remove(path_);
+ }
+
+ bool exists() const
+ {
+ return fs::exists(path_);
+ }
+
+ ~output_file_existence_checker()
+ {
+ try
+ {
+ fs::remove(path_);
+ }
+ catch(...)
+ {
+ }
+ }
+
+ private:
+ fs::path path_;
+};
+
+#endif // wx_test_output_hpp
diff --git a/wx_test_validate_output.cpp b/wx_test_validate_output.cpp
index 6ba33de..e04b958 100644
--- a/wx_test_validate_output.cpp
+++ b/wx_test_validate_output.cpp
@@ -32,53 +32,11 @@
#include "uncopyable_lmi.hpp"
#include "wx_test_case.hpp"
#include "wx_test_new.hpp"
+#include "wx_test_output.hpp"
#include
#include
-#include
-
-namespace
-{
-
-/// Class helping to check for the expected output file existence.
-///
-/// This class takes care of ensuring that the file doesn't exist when it is
-/// constructed and provides a way to check for the existence of the file
-/// later. It also cleans up the file when it is destroyed.
-
-class output_file_existence_checker
- :private lmi::uncopyable
-{
- public:
- output_file_existence_checker(std::string const& path)
- :path_(path)
- {
- fs::remove(path_);
- }
-
- bool exists() const
- {
- return fs::exists(path_);
- }
-
- ~output_file_existence_checker()
- {
- try
- {
- fs::remove(path_);
- }
- catch(...)
- {
- }
- }
-
- private:
- fs::path path_;
-};
-
-} // Unnamed namespace.
-
/*
Add test to validate existence of the expected output files.
--
1.7.9