Gromacs
2022.2
|
#include <testutils/include/testutils/interactivetest.h>
Helper class for testing interactive sessions.
The calling test can set the user input using setInputLines() (and possibly setLastNewline()), pass the streams from inputStream() and outputStream() to the code that executes the interactive session, and then call checkSession() after the session is finished. The input is provided from the array set with setInputLines(), and all output is checked using the reference data framework. The reference XML data can be viewed with the XSLT stylesheet to show exactly how the session went.
Public Member Functions | |
InteractiveTestHelper (gmx::test::TestReferenceChecker checker) | |
Initializes the helper. More... | |
void | setLastNewline (bool bInclude) |
Sets whether the last input line contains a newline (by default, it does). | |
void | setInputLines (const ArrayRef< const char *const > &inputLines) |
Sets the input lines for the interactive session. More... | |
TextInputStream & | inputStream () |
Returns the input stream for the session. | |
TextOutputStream & | outputStream () |
Returns the output stream for the session. | |
void | checkSession () |
Finalizes the checking for the session. More... | |
|
explicit |
Initializes the helper.
[in] | checker | Parent reference checker to use. |
The helper creates a compound item under checker
for the interactive session it tests.
void gmx::test::InteractiveTestHelper::checkSession | ( | ) |
Finalizes the checking for the session.
This must be called after all input and output from a session has occurred, as the helper will not otherwise know when output after the last input has finished. This method also checks that the required number of input lines were read in the session.
void gmx::test::InteractiveTestHelper::setInputLines | ( | const ArrayRef< const char *const > & | inputLines | ) |
Sets the input lines for the interactive session.
Calls to TextInputStream::readLine() will return strings from this array in sequence. Newlines are added at the end automatically (except for the last line if setLastNewLine(false)
has been called). If there are more readLine()
calls than there are input lines, the remaining calls return end-of-input.