Geogram Version 1.10.2
A programming library of geometric algorithms
Loading...
Searching...
No Matches
assert.h File Reference

Assertion checking mechanism. More...

#include <geogram/basic/common.h>
#include <string>

Go to the source code of this file.

Namespaces

namespace  GEO
 Global Vorpaline namespace.

Macros

#define GEO_ASSERTION(X)
#define GEO_NO_ASSERTION()
#define geo_assert(x)
 Verifies that a condition is met.
#define geo_range_assert(x, min_val, max_val)
 Verifies that a value is in a legal range.
#define geo_assert_not_reached
 Sets a non reachable point in the program.
#define geo_debug_assert(x)
 Verifies that a condition is met.
#define geo_debug_range_assert(x, min_val, max_val)
 Verifies that a value is in a legal range.
#define geo_debug(x)
#define geo_parano_assert(x)
 Verifies that a condition is met.
#define geo_parano_range_assert(x, min_val, max_val)
 Verifies that a value is in a legal range.

Enumerations

enum  GEO::AssertMode { GEO::ASSERT_THROW , GEO::ASSERT_ABORT , GEO::ASSERT_BREAKPOINT }
 Assert termination mode. More...

Functions

void GEO::set_assert_mode (AssertMode mode)
 Sets assertion mode.
AssertMode GEO::assert_mode ()
 Returns the current assert termination mode.
GEO_NORETURN_DECL void GEO::geo_abort () GEO_NORETURN
 Aborts the program.
GEO_NORETURN_DECL void GEO::geo_breakpoint () GEO_NORETURN
 Generates a debugger breakpoint programmatically.
GEO_NORETURN_DECL void GEO::geo_assertion_failed (const std::string &condition_string, const std::string &file, int line) GEO_NORETURN
 Prints an assertion failure.
GEO_NORETURN_DECL void GEO::geo_range_assertion_failed (double value, double min_value, double max_value, const std::string &file, int line) GEO_NORETURN
 Prints a range assertion failure.
GEO_NORETURN_DECL void GEO::geo_should_not_have_reached (const std::string &file, int line) GEO_NORETURN
 Prints an unreachable location failure.

Detailed Description

Assertion checking mechanism.

Definition in file assert.h.

Macro Definition Documentation

◆ geo_assert

#define geo_assert ( x)
Value:
GEO_ASSERTION({ \
if(!(x)) { \
GEO::geo_assertion_failed(#x, __FILE__, __LINE__); \
} \
})

Verifies that a condition is met.

Checks if the condition x. If the condition is false, it prints an error messages and terminates the program.

Parameters
[in]xthe boolean expression of the condition
See also
geo_assertion_failed()

Definition at line 155 of file assert.h.

◆ geo_assert_not_reached

#define geo_assert_not_reached
Value:
GEO_ASSERTION({ \
GEO::geo_should_not_have_reached(__FILE__, __LINE__); \
})

Sets a non reachable point in the program.

Definition at line 183 of file assert.h.

◆ GEO_ASSERTION

#define GEO_ASSERTION ( X)
Value:
do { X } while(false)

Definition at line 145 of file assert.h.

◆ geo_debug

#define geo_debug ( x)
Value:
GEO_NO_ASSERTION()

Definition at line 204 of file assert.h.

◆ geo_debug_assert

#define geo_debug_assert ( x)
Value:
GEO_NO_ASSERTION()

Verifies that a condition is met.

Checks if the condition x. If the condition is false, it prints an error messages and terminates the program.

Parameters
[in]xthe boolean expression of the condition
See also
geo_assertion_failed()
Note
This assertion check is only active in debug mode.

Definition at line 202 of file assert.h.

◆ geo_debug_range_assert

#define geo_debug_range_assert ( x,
min_val,
max_val )
Value:
GEO_NO_ASSERTION()

Verifies that a value is in a legal range.

Verifies that value x is in the range [min_value, max_value]. If this is false, it prints an error messages and terminates the program.

Parameters
[in]xthe value to verify
[in]min_valminimum allowed value
[in]max_valmaximum allowed value
See also
geo_range_assertion_failed()
Note
This assertion check is only active in debug mode.

Definition at line 203 of file assert.h.

◆ GEO_NO_ASSERTION

#define GEO_NO_ASSERTION ( )
Value:
do { } while(false)

Definition at line 146 of file assert.h.

◆ geo_parano_assert

#define geo_parano_assert ( x)
Value:
GEO_NO_ASSERTION()

Verifies that a condition is met.

Checks if the condition x. If the condition is false, it prints an error messages and terminates the program.

Parameters
[in]xthe boolean expression of the condition
See also
geo_assertion_failed()
Note
This assertion check is only active in paranoid mode.

Definition at line 221 of file assert.h.

◆ geo_parano_range_assert

#define geo_parano_range_assert ( x,
min_val,
max_val )
Value:
GEO_NO_ASSERTION()

Verifies that a value is in a legal range.

Verifies that value x is in the range [min_value, max_value]. If this is false, it prints an error messages and terminates the program.

Parameters
[in]xthe value to verify
[in]min_valminimum allowed value
[in]max_valmaximum allowed value
See also
geo_range_assertion_failed()
Note
This assertion check is only active in paranoid mode.

Definition at line 222 of file assert.h.

◆ geo_range_assert

#define geo_range_assert ( x,
min_val,
max_val )
Value:
GEO_ASSERTION({ \
if(((x) < (min_val)) || ((x) > (max_val))) { \
GEO::geo_range_assertion_failed(x, min_val, max_val, \
__FILE__, __LINE__ \
); \
} \
})

Verifies that a value is in a legal range.

Verifies that value x is in the range [min_value, max_value]. If this is false, it prints an error messages and terminates the program.

Parameters
[in]xthe value to verify
[in]min_valminimum allowed value
[in]max_valmaximum allowed value
See also
geo_range_assertion_failed()

Definition at line 171 of file assert.h.