Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_Assert.hpp
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 
10 #ifndef TEUCHOS_ASSERT_HPP
11 #define TEUCHOS_ASSERT_HPP
12 
13 
15 
16 
23 #define TEUCHOS_ASSERT(assertion_test) TEUCHOS_TEST_FOR_EXCEPT(!(assertion_test))
24 
25 #ifdef TEUCHOS_DEBUG
26 
30 #define TEUCHOS_DEBUG_ASSERT(assertion_test) TEUCHOS_ASSERT(assertion_test)
31 #else
32 #define TEUCHOS_DEBUG_ASSERT(assertion_test)
33 #endif
34 
35 
50 #define TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE( index, lower_inclusive, upper_exclusive ) \
51  { \
52  TEUCHOS_TEST_FOR_EXCEPTION( \
53  !( (lower_inclusive) <= (index) && (index) < (upper_exclusive) ), \
54  std::out_of_range, \
55  "Error, the index " #index " = " << (index) << " does not fall in the range" \
56  "["<<(lower_inclusive)<<","<<(upper_exclusive)<<")!" ); \
57  }
58 
59 
73 #define TEUCHOS_ASSERT_EQUALITY( val1, val2 ) \
74  { \
75  TEUCHOS_TEST_FOR_EXCEPTION( \
76  (val1) != (val2), std::out_of_range, \
77  "Error, (" #val1 " = " << (val1) << ") != (" #val2 " = " << (val2) << ")!" ); \
78  }
79 
80 
94 #define TEUCHOS_ASSERT_INEQUALITY( val1, comp, val2 ) \
95  { \
96  TEUCHOS_TEST_FOR_EXCEPTION( \
97  !( (val1) comp (val2) ), std::out_of_range, \
98  "Error, (" #val1 " = " << (val1) << ") " \
99  #comp " (" #val2 " = " << (val2) << ")! FAILED!" ); \
100  }
101 
102 
103 #endif // TEUCHOS_ASSERT_HPP
Standard test and throw macros.