diff options
| author | Albert Cervin <albert@acervin.com> | 2023-02-11 23:03:39 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2023-02-15 23:41:35 +0100 |
| commit | e45499816eab8abadbdd5bb6dd79b526a4ed6648 (patch) | |
| tree | 3cdcb0238aaae8ed1b3578e4ad71883f0702de3c /test/minibuffer.c | |
| parent | c2976cea9bbca465712534b7e523783e2ccc6c6e (diff) | |
| download | dged-e45499816eab8abadbdd5bb6dd79b526a4ed6648.tar.gz dged-e45499816eab8abadbdd5bb6dd79b526a4ed6648.tar.xz dged-e45499816eab8abadbdd5bb6dd79b526a4ed6648.zip | |
Implement undo
This also fixes a bunch of valgrind errors
Diffstat (limited to 'test/minibuffer.c')
| -rw-r--r-- | test/minibuffer.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/minibuffer.c b/test/minibuffer.c index dc29648..0e41c7b 100644 --- a/test/minibuffer.c +++ b/test/minibuffer.c @@ -2,12 +2,17 @@ #include "stdlib.h" #include "test.h" +#include "allocator.h" #include "buffer.h" #include "display.h" #include "minibuffer.h" static struct buffer b = {0}; +static struct frame_allocator *g_alloc = NULL; + +void *alloc_fn(size_t sz) { return frame_allocator_alloc(g_alloc, sz); } + void init() { if (b.name == NULL) { b = buffer_create("minibuffer", false); @@ -16,12 +21,21 @@ void init() { minibuffer_init(&b); } +void destroy() { + if (b.name != NULL) { + buffer_destroy(&b); + } +} + void test_minibuffer_echo() { uint32_t relline, relcol; // TODO: how to clear this? + struct frame_allocator alloc = frame_allocator_create(1024); + g_alloc = &alloc; + struct command_list *list = - command_list_create(10, malloc, 0, 0, "minibuffer"); + command_list_create(10, alloc_fn, 0, 0, "minibuffer"); init(); ASSERT(!minibuffer_displaying(), @@ -38,6 +52,10 @@ void test_minibuffer_echo() { buffer_update(&b, 100, 1, list, 0, &relline, &relcol); ASSERT(!minibuffer_displaying(), "A zero timeout echo should be cleared after first update"); + + frame_allocator_destroy(&alloc); + g_alloc = NULL; + destroy(); } int32_t fake(struct command_ctx ctx, int argc, const char *argv[]) { return 0; } @@ -64,6 +82,7 @@ void test_minibuffer_prompt() { minibuffer_abort_prompt(); ASSERT(!minibuffer_focused(), "Minibuffer must not be focused after prompt has been aborted"); + destroy(); } void run_minibuffer_tests() { |
