Remove gmx::File (except for File::exists())
[alexxy/gromacs.git] / src / gromacs / commandline / tests / cmdlinehelpmodule.cpp
index e5b9a139622863d985579b37ff9269a2504e1e06..5fada52c35de53dd3fec1d0fd73e1095e89bb9fe 100644 (file)
@@ -48,7 +48,7 @@
 #include "gromacs/commandline/cmdlinemodulemanager.h"
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/options.h"
-#include "gromacs/utility/file.h"
+#include "gromacs/utility/textwriter.h"
 
 #include "gromacs/onlinehelp/tests/mock_helptopic.h"
 #include "testutils/cmdlinetest.h"
@@ -74,14 +74,13 @@ TEST_F(CommandLineHelpModuleTest, PrintsGeneralHelp)
     };
     CommandLine       args(cmdline);
     initManager(args, "test");
-    redirectManagerOutput();
     addModule("module", "First module");
     addModule("other", "Second module");
     addHelpTopic("topic", "Test topic");
     int rc = 0;
     ASSERT_NO_THROW_GMX(rc = manager().run(args.argc(), args.argv()));
     ASSERT_EQ(0, rc);
-    checkRedirectedOutputFiles();
+    checkRedirectedOutput();
 }
 
 TEST_F(CommandLineHelpModuleTest, PrintsHelpOnTopic)
@@ -91,7 +90,6 @@ TEST_F(CommandLineHelpModuleTest, PrintsHelpOnTopic)
     };
     CommandLine       args(cmdline);
     initManager(args, "test");
-    redirectManagerOutput();
     addModule("module", "First module");
     MockHelpTopic &topic = addHelpTopic("topic", "Test topic");
     topic.addSubTopic("sub1", "Subtopic 1", "");
@@ -101,7 +99,7 @@ TEST_F(CommandLineHelpModuleTest, PrintsHelpOnTopic)
     int rc = 0;
     ASSERT_NO_THROW_GMX(rc = manager().run(args.argc(), args.argv()));
     ASSERT_EQ(0, rc);
-    checkRedirectedOutputFiles();
+    checkRedirectedOutput();
 }
 
 /*! \brief
@@ -125,10 +123,9 @@ TEST_F(CommandLineHelpModuleTest, ExportsHelp)
         "test", "help", "-export", "rst"
     };
     // TODO: Find a more elegant solution, or get rid of the links.dat altogether.
-    gmx::File::writeFileFromString("links.dat", "");
-    CommandLine       args(cmdline);
+    gmx::TextWriter::writeFileFromString("links.dat", "");
+    CommandLine        args(cmdline);
     initManager(args, "test");
-    redirectManagerOutput();
     MockOptionsModule &mod1 = addOptionsModule("module", "First module");
     MockOptionsModule &mod2 = addOptionsModule("other", "Second module");
     {
@@ -142,6 +139,7 @@ TEST_F(CommandLineHelpModuleTest, ExportsHelp)
     MockHelpTopic &topic1 = addHelpTopic("topic1", "Test topic");
     MockHelpTopic &sub1   = topic1.addSubTopic("sub1", "Subtopic 1", "Sub text");
     MockHelpTopic &sub2   = topic1.addSubTopic("sub2", "Subtopic 2", "Sub text");
+    MockHelpTopic &sub3   = topic1.addSubTopic("other", "Out-of-order subtopic", "Sub text");
     MockHelpTopic &topic2 = addHelpTopic("topic2", "Another topic");
     using ::testing::_;
     using ::testing::Invoke;
@@ -150,11 +148,12 @@ TEST_F(CommandLineHelpModuleTest, ExportsHelp)
     EXPECT_CALL(topic1, writeHelp(_));
     EXPECT_CALL(sub1, writeHelp(_));
     EXPECT_CALL(sub2, writeHelp(_));
+    EXPECT_CALL(sub3, writeHelp(_));
     EXPECT_CALL(topic2, writeHelp(_));
     int rc = 0;
     ASSERT_NO_THROW_GMX(rc = manager().run(args.argc(), args.argv()));
     ASSERT_EQ(0, rc);
-    checkRedirectedOutputFiles();
+    checkRedirectedOutput();
     std::remove("links.dat");
 }