10 #include "Thyra_TestingTools.hpp"
14 const std::string &boolExprName,
16 const bool &boolExpected,
21 const bool success = ( boolExpr == boolExpected );
25 << li <<
"Check: " << boolExprName <<
" = " << boolExpr <<
" == " << boolExpected
26 <<
" : " <<
passfail(success) << std::endl;
32 void Thyra::printTestResults(
34 const std::string &test_summary,
35 const bool show_all_tests,
36 const Ptr<bool> &success,
37 const Ptr<std::ostream> &out
40 if (!result) *success =
false;
42 if (!result || show_all_tests) {
43 *out << std::endl << test_summary;
58 TestResultsPrinter::TestResultsPrinter(
60 : out_(out.assert_not_null()), show_all_tests_(show_all_tests),
61 printedTestResults_(false)
63 if (show_all_tests_) {
67 oss_ = Teuchos::fancyOStream(Teuchos::rcpFromRef(ossStore_));
68 ossStore_.copyfmt(*out_);
75 using Teuchos::inoutArg;
76 if (!printedTestResults_) {
81 bool dummy_success =
true;
89 printedTestResults_ =
true;
111 if (!show_all_tests_) {
112 Thyra::printTestResults(this_result, ossStore_.str(),
false,
113 success, out_.
ptr());
120 printedTestResults_ =
true;
const std::string passfail(const bool result)
RCP< FancyOStream > replaceOStream(const RCP< FancyOStream > &out)
Replace the underlying output stream (used for unit testing this class).
void printTestResults(const bool this_result, const Ptr< bool > &success)
Print the test result.
~TestResultsPrinter()
Print the test results on destruction if not already printed.
bool nonnull(const boost::shared_ptr< T > &p)
RCP< FancyOStream > getTestOStream()
Return the stream used for testing.
bool testBoolExpr(const std::string &boolExprName, const bool &boolExpr, const bool &boolExpected, const Ptr< std::ostream > &out, const std::string &leadingIndent=std::string(""))
Check a boolean result against expected result.