summaryrefslogtreecommitdiff
path: root/test/minibuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/minibuffer.c')
-rw-r--r--test/minibuffer.c21
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() {