Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_TestingHelpers.cpp
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
11 #include "Teuchos_toString.hpp"
12 
13 
14 namespace {
15 
16 
17 // Make sure this is initialized whenever needed before main starts!
18 bool& showTestFailureLocationImpl()
19 {
20  static bool showTFL = false;
21  return showTFL;
22 }
23 
24 
25 } // namespace
26 
27 
28 const std::string
30  const std::string &file, const int lineNumber)
31 {
32  std::string rtn = passfail(result);
33  if (!result && showTestFailureLocation()) {
34  rtn += " ==> "+file+":"+toString(lineNumber);
35  }
36  return rtn;
37 }
38 
39 
41 {
42  showTestFailureLocationImpl() = showTFL;
43 }
44 
45 
47 {
48  return showTestFailureLocationImpl();
49 }
TEUCHOSCORE_LIB_DLL_EXPORT const std::string passfail_with_location(const bool result, const std::string &file, const int lineNumber)
Helper function for TEUCHOS_PASS_FAIL(...).
const std::string passfail(const bool result)
Return "passed" or "failed".
std::string toString(const any &rhs)
Converts the value in any to a std::string.
void showTestFailureLocation(bool)
Set if TEUCHOS_PASS_FAIL(...) should print test failure location.
Utilities to make writing tests easier.