Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UnitTest_UnitTests.cpp
Go to the documentation of this file.
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_dyn_cast.hpp"
12 
13 
14 namespace {
15 
16 
17 TEUCHOS_UNIT_TEST( UnitTest, verbose )
18 {
19  // This test checks to see that the 'verbose' bool is returned correctly.
20  // This test uses knowlege of the internals of
21  // Teuchos::UnitTestRepository::runUnitTests(...) to determine if this is
22  // set correctly according to the --details input option. This test is
23  // *very* closely tied to the interneral implemetation of
24  // Teuchos::UnitTestRepository.
25  using Teuchos::dyn_cast;
26  using Teuchos::rcp_dynamic_cast;
29  const Teuchos::RCP<std::ostream> wrappedOut = out.getOStream();
30  if (verbose) {
31  TEST_THROW(dyn_cast<std::ostringstream>(*wrappedOut), Teuchos::m_bad_cast);
32  }
33  else {
34  TEST_NOTHROW(dyn_cast<std::ostringstream>(*wrappedOut));
35  }
36 }
37 
38 
39 } // namespace
static bool verboseUnitTests()
Returns if unit tests are verbose or not.
#define TEST_NOTHROW(code)
Asserr that the statement &#39;code&#39; does not thrown any excpetions.
#define TEST_THROW(code, ExceptType)
Assert that the statement &#39;code&#39; throws the exception &#39;ExceptType&#39; (otherwise the test fails)...
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
T_To & dyn_cast(T_From &from)
Dynamic casting utility function meant to replace dynamic_cast&lt;T&amp;&gt; by throwing a better documented er...
Unit testing support.
Exception class for bad cast.
basic_FancyOStream< char > FancyOStream