mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-09 08:21:01 -04:00
macros: add UNITTEST macro and use to replace test_keymap_lookup()
This commit is contained in:
parent
360946917c
commit
3d9302b6f9
2 changed files with 17 additions and 4 deletions
5
input.c
5
input.c
|
|
@ -884,9 +884,7 @@ keymap_lookup(struct terminal *term, xkb_keysym_t sym, enum modifier mods)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_DEBUG)
|
UNITTEST
|
||||||
static void __attribute__((constructor))
|
|
||||||
test_keymap_lookup(void)
|
|
||||||
{
|
{
|
||||||
struct terminal term = {
|
struct terminal term = {
|
||||||
.num_lock_modifier = false,
|
.num_lock_modifier = false,
|
||||||
|
|
@ -897,7 +895,6 @@ test_keymap_lookup(void)
|
||||||
const struct key_data *info = keymap_lookup(&term, XKB_KEY_ISO_Left_Tab, MOD_SHIFT | MOD_CTRL);
|
const struct key_data *info = keymap_lookup(&term, XKB_KEY_ISO_Left_Tab, MOD_SHIFT | MOD_CTRL);
|
||||||
xassert(strcmp(info->seq, "\033[27;6;9~") == 0);
|
xassert(strcmp(info->seq, "\033[27;6;9~") == 0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
|
key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
|
||||||
|
|
|
||||||
16
macros.h
16
macros.h
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define PASTE(a, b) a##b
|
||||||
|
#define XPASTE(a, b) PASTE(a, b)
|
||||||
#define DO_PRAGMA(x) _Pragma(#x)
|
#define DO_PRAGMA(x) _Pragma(#x)
|
||||||
#define VERCMP(x, y, cx, cy) ((cx > x) || ((cx == x) && (cy >= y)))
|
#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)
|
#if GNUC_AT_LEAST(3, 0) || HAS_ATTRIBUTE(constructor)
|
||||||
#define CONSTRUCTOR __attribute__((__constructor__))
|
#define CONSTRUCTOR __attribute__((__constructor__))
|
||||||
|
#define HAVE_ATTR_CONSTRUCTOR 1
|
||||||
#else
|
#else
|
||||||
#define CONSTRUCTOR
|
#define CONSTRUCTOR
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -175,6 +178,19 @@
|
||||||
#define UNROLL_LOOP(n)
|
#define UNROLL_LOOP(n)
|
||||||
#endif
|
#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__
|
#ifdef __clang__
|
||||||
#define IGNORE_WARNING(wflag) \
|
#define IGNORE_WARNING(wflag) \
|
||||||
DO_PRAGMA(clang diagnostic push) \
|
DO_PRAGMA(clang diagnostic push) \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue