Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_CWrapperSupport_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 "someCFunc.h"
12 
14 
15 
16 namespace {
17 
18 
19 void unitTestSetup(Teuchos::FancyOStream &out)
20 {
22  Teuchos::rcpFromRef(out));
23 }
24 
25 
26 TEUCHOS_UNIT_TEST( CWrapperErrorHandling, normalReturn )
27 {
28  unitTestSetup(out);
29  int ierr = 0;
30  ECHO(const int output = someCFunc(1, &ierr));
31  TEST_EQUALITY_CONST(output, 1);
32  TEST_EQUALITY_CONST(ierr, 0);
33 }
34 
35 
36 TEUCHOS_UNIT_TEST( CWrapperErrorHandling, throwReturnErrorCode )
37 {
38  unitTestSetup(out);
39  int ierr = 0;
40  ECHO(const int output = someCFunc(-3, &ierr));
41  TEST_EQUALITY_CONST(output, -1);
42  TEST_EQUALITY_CONST(ierr, -1);
43 }
44 
45 
46 TEUCHOS_UNIT_TEST( CWrapperErrorHandling, nonthrowErrorReturn )
47 {
48  unitTestSetup(out);
49  int ierr = 0;
50  ECHO(const int output = someCFunc(11, &ierr));
51  TEST_EQUALITY_CONST(output, -1);
52  TEST_EQUALITY_CONST(ierr, -2);
53 }
54 
55 
56 } // namespace
#define ECHO(statement)
Echo the given statement before it is executed.
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
std::ostream subclass that performs the magic of indenting data sent to an std::ostream object among ...
Unit testing support.
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2.
static void setPrintErrorOStream(const RCP< FancyOStream > &errorOStream)
Set the ostream that will be printed to when errors occur.
int someCFunc(int input, int *ierr)
Definition: someCFunc.cpp:17