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;
90 TestResultsPrinter::TestResultsPrinter(
92 : out_(out.assert_not_null()), show_all_tests_(show_all_tests),
93 printedTestResults_(false)
95 if (show_all_tests_) {
99 oss_ = Teuchos::fancyOStream(Teuchos::rcpFromRef(ossStore_));
100 ossStore_.copyfmt(*out_);
107 using Teuchos::inoutArg;
108 if (!printedTestResults_) {
113 bool dummy_success =
true;
121 printedTestResults_ =
true;
143 if (!show_all_tests_) {
144 Thyra::printTestResults(this_result, ossStore_.str(),
false,
145 success, out_.
ptr());
152 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.