macros: add UNITTEST macro and use to replace test_keymap_lookup()

This commit is contained in:
Craig Barnes 2021-05-25 18:38:16 +01:00 committed by Daniel Eklöf
parent 360946917c
commit 3d9302b6f9
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 17 additions and 4 deletions

View file

@ -1,5 +1,7 @@
#pragma once
#define PASTE(a, b) a##b
#define XPASTE(a, b) PASTE(a, b)
#define DO_PRAGMA(x) _Pragma(#x)
#define VERCMP(x, y, cx, cy) ((cx > x) || ((cx == x) && (cy >= y)))
@ -68,6 +70,7 @@
#if GNUC_AT_LEAST(3, 0) || HAS_ATTRIBUTE(constructor)
#define CONSTRUCTOR __attribute__((__constructor__))
#define HAVE_ATTR_CONSTRUCTOR 1
#else
#define CONSTRUCTOR
#endif
@ -175,6 +178,19 @@
#define UNROLL_LOOP(n)
#endif
#ifdef __COUNTER__
// Supported by GCC 4.3+ and Clang
#define COUNTER_ __COUNTER__
#else
#define COUNTER_ __LINE__
#endif
#if defined(_DEBUG) && defined(HAVE_ATTR_CONSTRUCTOR)
#define UNITTEST static void CONSTRUCTOR XPASTE(unittest_, COUNTER_)(void)
#else
#define UNITTEST static void UNUSED XPASTE(unittest_, COUNTER_)(void)
#endif
#ifdef __clang__
#define IGNORE_WARNING(wflag) \
DO_PRAGMA(clang diagnostic push) \