Flow123d  master-f44eb46
Classes | Namespaces | Macros
asserts.hh File Reference

Definitions of ASSERTS. More...

#include <iostream>
#include <string>
#include <vector>
#include "system/global_defs.h"
#include "system/exceptions.hh"
#include "system/fmt/posix.h"

Go to the source code of this file.

Classes

class  feal::Exc_assert
 Helper class. More...
 
class  feal::Assert
 Class defining debugging messages. More...
 
class  feal::AssertNull
 

Namespaces

 feal
 

Macros

#define _FEAL_ASSERT_A(x)   _FEAL_ASSERT_OP(x, B)
 Internal clever macro A. More...
 
#define _FEAL_ASSERT_B(x)   _FEAL_ASSERT_OP(x, A)
 Internal clever macro B. More...
 
#define _FEAL_ASSERT_OP(x, next)    _FEAL_ASSERT_A.add_value((x), #x)._FEAL_ASSERT_ ## next
 Internal clever macro recursion. More...
 
#define FEAL_ASSERT_PERMANENT(expr)
 Definition of assert for debug and release mode. More...
 
#define FEAL_ASSERT(expr)
 Definition of assert for debug mode only. More...
 
#define ASSERT_PERMANENT_LT(a, b)    FEAL_ASSERT_PERMANENT(a < b)(a)(b)
 Definition of comparative assert macro (Less Than) More...
 
#define ASSERT_LT(a, b)    FEAL_ASSERT(a < b)(a)(b)
 Definition of comparative assert macro (Less Than) only for debug mode. More...
 
#define ASSERT_PERMANENT_LE(a, b)    FEAL_ASSERT_PERMANENT(a <= b)(a)(b)
 Definition of comparative assert macro (Less or Equal) More...
 
#define ASSERT_LE(a, b)    FEAL_ASSERT(a <= b)(a)(b)
 Definition of comparative assert macro (Less or Equal) only for debug mode. More...
 
#define ASSERT_PERMANENT_GT(a, b)    FEAL_ASSERT_PERMANENT(a > b)(a)(b)
 Definition of comparative assert macro (Greater Than) More...
 
#define ASSERT_GT(a, b)    FEAL_ASSERT(a > b)(a)(b)
 Definition of comparative assert macro (Greater Than) only for debug mode. More...
 
#define ASSERT_PERMANENT_GE(a, b)    FEAL_ASSERT_PERMANENT(a >= b)(a)(b)
 Definition of comparative assert macro (Greater or Equal) More...
 
#define ASSERT_GE(a, b)    FEAL_ASSERT(a >= b)(a)(b)
 Definition of comparative assert macro (Greater or Equal) only for debug mode. More...
 
#define ASSERT_PERMANENT_EQ(a, b)    FEAL_ASSERT_PERMANENT(a == b)(a)(b)
 Definition of comparative assert macro (EQual) More...
 
#define ASSERT_EQ(a, b)    FEAL_ASSERT(a == b)(a)(b)
 Definition of comparative assert macro (EQual) only for debug mode. More...
 
#define ASSERT_PERMANENT_PTR(ptr)    FEAL_ASSERT_PERMANENT( (ptr) != nullptr )
 Definition of assert macro checking non-null pointer (PTR) More...
 
#define ASSERT_PTR(ptr)    FEAL_ASSERT( (ptr) != nullptr )
 Definition of assert macro checking non-null pointer (PTR) only for debug mode. More...
 
#define ASSERT_PERMANENT(expr)   FEAL_ASSERT_PERMANENT( expr)
 Allow use shorter versions of macro names if these names is not used with external library. More...
 
#define ASSERT(expr)   FEAL_ASSERT( expr)
 

Detailed Description

Definitions of ASSERTS.

 * Copyright (C) 2015 Technical University of Liberec. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Definition in file asserts.hh.

Macro Definition Documentation

◆ _FEAL_ASSERT_A

#define _FEAL_ASSERT_A (   x)    _FEAL_ASSERT_OP(x, B)

Internal clever macro A.

Definitions of internal macros

Definition at line 223 of file asserts.hh.

◆ _FEAL_ASSERT_B

#define _FEAL_ASSERT_B (   x)    _FEAL_ASSERT_OP(x, A)

Internal clever macro B.

Definition at line 225 of file asserts.hh.

◆ _FEAL_ASSERT_OP

#define _FEAL_ASSERT_OP (   x,
  next 
)     _FEAL_ASSERT_A.add_value((x), #x)._FEAL_ASSERT_ ## next

Internal clever macro recursion.

Definition at line 227 of file asserts.hh.

◆ ASSERT

#define ASSERT (   expr)    FEAL_ASSERT( expr)

Definition at line 351 of file asserts.hh.

◆ ASSERT_EQ

#define ASSERT_EQ (   a,
 
)     FEAL_ASSERT(a == b)(a)(b)

Definition of comparative assert macro (EQual) only for debug mode.

Definition at line 333 of file asserts.hh.

◆ ASSERT_GE

#define ASSERT_GE (   a,
 
)     FEAL_ASSERT(a >= b)(a)(b)

Definition of comparative assert macro (Greater or Equal) only for debug mode.

Definition at line 325 of file asserts.hh.

◆ ASSERT_GT

#define ASSERT_GT (   a,
 
)     FEAL_ASSERT(a > b)(a)(b)

Definition of comparative assert macro (Greater Than) only for debug mode.

Definition at line 317 of file asserts.hh.

◆ ASSERT_LE

#define ASSERT_LE (   a,
 
)     FEAL_ASSERT(a <= b)(a)(b)

Definition of comparative assert macro (Less or Equal) only for debug mode.

Definition at line 309 of file asserts.hh.

◆ ASSERT_LT

#define ASSERT_LT (   a,
 
)     FEAL_ASSERT(a < b)(a)(b)

Definition of comparative assert macro (Less Than) only for debug mode.

Definition at line 301 of file asserts.hh.

◆ ASSERT_PERMANENT

#define ASSERT_PERMANENT (   expr)    FEAL_ASSERT_PERMANENT( expr)

Allow use shorter versions of macro names if these names is not used with external library.

Definition at line 348 of file asserts.hh.

◆ ASSERT_PERMANENT_EQ

#define ASSERT_PERMANENT_EQ (   a,
 
)     FEAL_ASSERT_PERMANENT(a == b)(a)(b)

Definition of comparative assert macro (EQual)

Definition at line 329 of file asserts.hh.

◆ ASSERT_PERMANENT_GE

#define ASSERT_PERMANENT_GE (   a,
 
)     FEAL_ASSERT_PERMANENT(a >= b)(a)(b)

Definition of comparative assert macro (Greater or Equal)

Definition at line 321 of file asserts.hh.

◆ ASSERT_PERMANENT_GT

#define ASSERT_PERMANENT_GT (   a,
 
)     FEAL_ASSERT_PERMANENT(a > b)(a)(b)

Definition of comparative assert macro (Greater Than)

Definition at line 313 of file asserts.hh.

◆ ASSERT_PERMANENT_LE

#define ASSERT_PERMANENT_LE (   a,
 
)     FEAL_ASSERT_PERMANENT(a <= b)(a)(b)

Definition of comparative assert macro (Less or Equal)

Definition at line 305 of file asserts.hh.

◆ ASSERT_PERMANENT_LT

#define ASSERT_PERMANENT_LT (   a,
 
)     FEAL_ASSERT_PERMANENT(a < b)(a)(b)

Definition of comparative assert macro (Less Than)

Definition at line 297 of file asserts.hh.

◆ ASSERT_PERMANENT_PTR

#define ASSERT_PERMANENT_PTR (   ptr)     FEAL_ASSERT_PERMANENT( (ptr) != nullptr )

Definition of assert macro checking non-null pointer (PTR)

Definition at line 337 of file asserts.hh.

◆ ASSERT_PTR

#define ASSERT_PTR (   ptr)     FEAL_ASSERT( (ptr) != nullptr )

Definition of assert macro checking non-null pointer (PTR) only for debug mode.

Definition at line 341 of file asserts.hh.

◆ FEAL_ASSERT

#define FEAL_ASSERT (   expr)
Value:
if ( !(expr) ) \
feal::AssertNull()._FEAL_ASSERT_A

Definition of assert for debug mode only.

Definition at line 291 of file asserts.hh.

◆ FEAL_ASSERT_PERMANENT

#define FEAL_ASSERT_PERMANENT (   expr)
Value:
if ( !(expr) ) \
feal::Assert( #expr).set_context( __FILE__, __func__, __LINE__)._FEAL_ASSERT_A

Definition of assert for debug and release mode.

Undefining redefinitions of comparsion macros.

You can define FEAL_OVERRIDE_ASSERTS (e.g. in unit tests) and undefine macros with same name in external libraries. Definitions of assert macros

Definition at line 281 of file asserts.hh.