Medusa  1.1
Coordinate Free Mehless Method implementation
assert.hpp File Reference

Detailed Description

Implementation of custom assert and debug utilities.

Definition in file assert.hpp.

#include <tinyformat/tinyformat.h>
#include "print.hpp"
+ Include dependency graph for assert.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 mm
 Root namespace for the whole library.
 
 mm::assert_internal
 Namespace holding custom assert implementation.
 

Macros

#define prn(...)   macro_dispatcher(prnv, __VA_ARGS__)(__VA_ARGS__)
 Prints a variable name and value to standard output. More...
 
#define assert_msg(cond, ...)
 Assert with better error reporting. More...
 

Functions

bool mm::assert_internal::assert_handler_implementation (const char *condition, const char *file, const char *func_name, int line, const char *message, tfm::FormatListRef format_list)
 Actual assert implementation. More...
 
template<typename... Args>
bool mm::assert_internal::assert_handler (const char *condition, const char *file, const char *func_name, int line, const char *message, const Args &... args)
 Assert handler that unpacks varargs. More...
 
void mm::print_red (const std::string &s)
 Prints given text in bold red. More...
 
void mm::print_white (const std::string &s)
 Prints given text in bold white. More...
 
void mm::print_green (const std::string &s)
 Prints given text in bold green. More...
 

Macro Definition Documentation

◆ assert_msg

#define assert_msg (   cond,
  ... 
)
Value:
((void)(!(cond) && \
#cond, __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) && (assert(0), 1)))

Assert with better error reporting.

Parameters
condConditions to test.
...The second parameter is also required and represents the message to print on failure. For every %* field in message one additional parameter must be present.

Example:

assert_msg(n > 0, "n must be positive, got %d.", n);

Definition at line 75 of file assert.hpp.

◆ prn

#define prn (   ...)    macro_dispatcher(prnv, __VA_ARGS__)(__VA_ARGS__)

Prints a variable name and value to standard output.

Can take one or two parameters. Example:

int a = 6;
prn(a) // prints 'a = 6;'
prn("value", a) // prints 'value = 6;'
Examples
test/domains/BasicRelax_test.cpp.

Definition at line 34 of file assert.hpp.

assert_msg
#define assert_msg(cond,...)
Assert with better error reporting.
Definition: assert.hpp:75
mm::assert_internal::assert_handler
bool assert_handler(const char *condition, const char *file, const char *func_name, int line, const char *message, const Args &... args)
Assert handler that unpacks varargs.
Definition: assert.hpp:54
prn
#define prn(...)
Prints a variable name and value to standard output.
Definition: assert.hpp:34