HyperHDG
|
This file provides the function hy_assert
.
More...
#include <iostream>
#include <sstream>
Go to the source code of this file.
Macros | |
#define | hy_assert(Expr, Msg) |
The assertion to be used within HyperHDG — deactivate using -DNDEBUG compile flag. More... | |
This file provides the function hy_assert
.
This is a wrapper file to provide a function that allows to use assertions that are similar to those provided by cassert. That is, we define a macro hy_assert
that implements assert. If a user wants to use assertions, it is recommended to use hy_assert
(Expr
, Msg
). The use of the function __Hy_Assert
is not recommended.
Function hy_assert
takes two arguments. The first argument is evaluated to a boolean
and if this returns true
, nothing is done. If the argument is false
, the running program is terminated and the second argument is displayed as part of an error message. Here, the second argument is handled as a stringstream
(without initial <<
). Thus, for two integers a and b, a function call might look like: hy_assert( a == b , "Integers have not been the same, since a
turned out to be " << a << " and b was " << b << "." );
Whether this functionality is active or not can be deduced via setting NDEBUG
, when the code is compiled. Using this functionality makes your program significantly slower. However, usage is highly recommended for testing.
#define hy_assert | ( | Expr, | |
Msg | |||
) |
The assertion to be used within HyperHDG — deactivate using -DNDEBUG compile flag.
Expr | C++ Expression that can be evaluated to true or false . |
Msg | Message that is to be displayed if Expr is evaluated to false . |