Make some unit tests use mock file output
[alexxy/gromacs.git] / src / gromacs / onlinehelp / tests / helpmanager.cpp
index f28b0f8e12cdca9a5bc176cd78eeaf1968c0522c..05dfb2438202bc87f0774dcc69adee9053572f83 100644 (file)
 #include "gromacs/onlinehelp/helptopic.h"
 #include "gromacs/onlinehelp/helpwritercontext.h"
 #include "gromacs/utility/exceptions.h"
-#include "gromacs/utility/file.h"
+#include "gromacs/utility/stringstream.h"
 
 #include "gromacs/onlinehelp/tests/mock_helptopic.h"
 #include "testutils/stringtest.h"
 #include "testutils/testasserts.h"
-#include "testutils/testfilemanager.h"
 
 namespace
 {
@@ -68,18 +67,14 @@ class HelpTestBase : public gmx::test::StringTestBase
     public:
         HelpTestBase();
 
-        gmx::test::TestFileManager tempFiles_;
         MockHelpTopic              rootTopic_;
-        std::string                filename_;
-        gmx::File                  helpFile_;
+        gmx::StringOutputStream    helpFile_;
         gmx::HelpWriterContext     context_;
         gmx::HelpManager           manager_;
 };
 
 HelpTestBase::HelpTestBase()
     : rootTopic_("", NULL, "Root topic text"),
-      filename_(tempFiles_.getTemporaryFilePath("helptext.txt")),
-      helpFile_(filename_, "w"),
       context_(&helpFile_, gmx::eHelpOutputFormat_Console),
       manager_(rootTopic_, context_)
 {
@@ -158,7 +153,7 @@ void HelpTopicFormattingTest::checkHelpFormatting()
     ASSERT_NO_THROW_GMX(manager_.writeCurrentTopic());
     helpFile_.close();
 
-    checkFileContents(filename_, "HelpText");
+    checkText(helpFile_.toString(), "HelpText");
 }
 
 TEST_F(HelpTopicFormattingTest, FormatsSimpleTopic)