Custom program context for unit tests
[alexxy/gromacs.git] / src / testutils / testfilemanager.cpp
index 0a2eb0f9e38b05839fad9df8d928b4092ce314a2..da988ea99ae12f9f15848147faedd1b156936d92 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -76,7 +76,7 @@ class TestFileManager::Impl
 {
     public:
         //! Global test input data path set with setDataInputDirectory().
-        static const char *s_inputDirectory;
+        static std::string s_inputDirectory;
 
         //! Global temporary output directory for tests, set with setGlobalOutputTempDirectory().
         static const char *s_globalOutputTempDirectory;
@@ -111,7 +111,7 @@ class TestFileManager::Impl
         std::string outputTempDirectory_;
 };
 
-const char *TestFileManager::Impl::s_inputDirectory            = NULL;
+std::string TestFileManager::Impl::s_inputDirectory;
 const char *TestFileManager::Impl::s_globalOutputTempDirectory = NULL;
 /** Controls whether TestFileManager should delete temporary files
     after the test finishes. */
@@ -200,8 +200,8 @@ std::string TestFileManager::getInputFilePath(const char *filename)
 
 const char *TestFileManager::getInputDataDirectory()
 {
-    GMX_RELEASE_ASSERT(Impl::s_inputDirectory != NULL, "Path for test input files is not set");
-    return Impl::s_inputDirectory;
+    GMX_RELEASE_ASSERT(!Impl::s_inputDirectory.empty(), "Path for test input files is not set");
+    return Impl::s_inputDirectory.c_str();
 }
 
 const char *TestFileManager::getGlobalOutputTempDirectory()
@@ -215,7 +215,7 @@ const char *TestFileManager::getOutputTempDirectory() const
     return impl_->outputTempDirectory_.c_str();
 }
 
-void TestFileManager::setInputDataDirectory(const char *path)
+void TestFileManager::setInputDataDirectory(const std::string &path)
 {
     // There is no need to protect this by a mutex, as this is called in early
     // initialization of the tests.