refactor(test): use simpler ASSERT wrapper

This commit is contained in:
Johann Dreo 2022-08-29 09:47:58 +02:00
commit be48aad4ec
2 changed files with 6 additions and 6 deletions

View file

@ -314,9 +314,9 @@ The `CLUTHFUNC` macro allows to wrap any function within the current logger.
For instance, this can be useful if you want to (de)clutch calls to `assert`s. For instance, this can be useful if you want to (de)clutch calls to `assert`s.
To do that, just declare your own macro: To do that, just declare your own macro:
```cpp ```cpp
#define ASSERT(LEVEL, ...) { CLUTCHFUNC(LEVEL, assert, __VA_ARGS__) } #define ASSERT(...) { CLUTCHFUNC(error, assert, __VA_ARGS__) }
``` ```
Thus, any call like `ASSERT(error, x > 3);` will be declutchable Thus, any call like `ASSERT(x > 3);` will be declutchable
with the same configuration than a call to `CLUTCHLOG`. with the same configuration than a call to `CLUTCHLOG`.

View file

@ -4,26 +4,26 @@
#include "../clutchlog/clutchlog.h" #include "../clutchlog/clutchlog.h"
// Make asserts (de)clutchable. // Make asserts (de)clutchable.
#define ASSERT(LEVEL, ...) CLUTCHFUNC(LEVEL, assert, __VA_ARGS__); #define ASSERT(...) CLUTCHFUNC(error, assert, __VA_ARGS__);
void h() void h()
{ {
CLUTCHLOG(info, "!"); CLUTCHLOG(info, "!");
ASSERT(info, true == true); ASSERT(true == true);
std::clog << "--" << std::endl; std::clog << "--" << std::endl;
} }
void g() void g()
{ {
CLUTCHLOG(warning, "world"); CLUTCHLOG(warning, "world");
ASSERT(warning, strcmp("life","life") == 0); ASSERT(strcmp("life","life") == 0);
h(); h();
} }
void f() void f()
{ {
CLUTCHLOG(error, "hello "); CLUTCHLOG(error, "hello ");
ASSERT(error, strcmp("no more","please")!=0); ASSERT(strcmp("no more","please")!=0);
g(); g();
} }