42 #include "Thyra_TestingTools.hpp"
46 const std::string &boolExprName,
48 const bool &boolExpected,
53 const bool success = ( boolExpr == boolExpected );
57 << li <<
"Check: " << boolExprName <<
" = " << boolExpr <<
" == " << boolExpected
58 <<
" : " <<
passfail(success) << std::endl;
64 void Thyra::printTestResults(
66 const std::string &test_summary,
67 const bool show_all_tests,
68 const Ptr<bool> &success,
69 const Ptr<std::ostream> &out
72 if (!result) *success =
false;
74 if (!result || show_all_tests) {
75 *out << std::endl << test_summary;
84 void Thyra::printTestResults(
86 const std::string &test_summary,
87 const bool show_all_tests,
93 printTestResults(result, test_summary, show_all_tests,
94 ptr(success), ptr(out));
104 TestResultsPrinter::TestResultsPrinter(
106 : out_(out.assert_not_null()), show_all_tests_(show_all_tests),
107 printedTestResults_(false)
109 if (show_all_tests_) {
113 oss_ = Teuchos::fancyOStream(Teuchos::rcpFromRef(ossStore_));
114 ossStore_.copyfmt(*out_);
121 using Teuchos::inoutArg;
122 if (!printedTestResults_) {
127 bool dummy_success =
true;
135 printedTestResults_ =
true;
157 if (!show_all_tests_) {
158 Thyra::printTestResults(this_result, ossStore_.str(),
false,
159 success, out_.
ptr());
166 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.