Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UnitTestHarness_Parallel_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 
12 #include "Teuchos_DefaultComm.hpp"
13 #include "Teuchos_CommHelpers.hpp"
14 
16 
17 
18 namespace Teuchos {
19 
20 
21 TEUCHOS_UNIT_TEST( UnitTestHarness, nonRootFails ) {
22  out << "Pass on even procs but fail on other procs!\n";
24  const int procRank = comm->getRank();
25  TEST_EQUALITY_CONST(procRank%2, 0);
26 }
27 
28 
29 TEUCHOS_UNIT_TEST( UnitTestHarness, nonRootThrowsTeuchosExcept ) {
30  out << "Pass on even procs but throws Teuchos exception on other processes!\n";
32  const int procRank = comm->getRank();
33  TEUCHOS_ASSERT_EQUALITY(procRank%2, 0); // Throws on non-root processes
34  int myval = 1;
35  TEST_EQUALITY_CONST(myval, 1);
36 }
37 
38 
39 TEUCHOS_UNIT_TEST( UnitTestHarness, nonRootThrowsIntExcept ) {
40  out << "Pass on even procs but throws int exception on other processes!\n";
42  const int procRank = comm->getRank();
43  if (procRank%2 != 0) {
44  throw procRank;
45  }
46  int myval = 1;
47  TEST_EQUALITY_CONST(myval, 1);
48 }
49 
50 
51 } // namespace Teuchos
52 
53 
54 
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
Return the default global communicator.
TEUCHOS_UNIT_TEST(ConstNonconstObjectContainer, create)
Templated Parameter List class.
Unit testing support.
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2.
Additional ParameterList XML helper functions including parallel support.
Smart reference counting pointer class for automatic garbage collection.
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
This macro is checks that to numbers are equal and if not then throws an exception with a good error ...