From c6294f163f91fd2ff9460910f97ab9fdd9b43dd0 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 2 Jun 2019 19:11:22 -0400 Subject: [PATCH] Okay, added uiFreeEvent() error tests. Now back to uiControl. --- test/events.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/events.c b/test/events.c index 792dcb8a..0e94dfc3 100644 --- a/test/events.c +++ b/test/events.c @@ -756,6 +756,8 @@ static void testWhileFiring(void *sender, void *args, void *data) idPlaceholder = 0; blockedPlaceholder = false; + testProgrammerError(t, uiFreeEvent(firingEvent), + "attempt to change a uiEvent with uiFreeEvent() while it is firing"); testProgrammerError(t, uiEventAddHandler(firingEvent, handler, senderPlaceholder, dataPlaceholder), "attempt to change a uiEvent with uiEventAddHandler() while it is firing"); testProgrammerError(t, uiEventDeleteHandler(firingEvent, idPlaceholder), @@ -807,6 +809,10 @@ testingTest(EventErrors) nonglobalEvent = uiNewEvent(&opts); testingTDefer(t, deferFreeEvent, nonglobalEvent); + testProgrammerError(t, uiFreeEvent(NULL), + "invalid null pointer for uiEvent passed into uiFreeEvent()"); + // We test trying to free a uiEvent with handlers later, when we actually need to make one for testing firing. + eventPlaceholder = globalEvent; senderPlaceholder = NULL; argsPlaceholder = NULL; @@ -858,5 +864,7 @@ testingTest(EventErrors) fp->e = firingEvent; fp->id = uiEventAddHandler(fp->e, testWhileFiring, NULL, t); testingTDefer(t, deferDeleteFiringHandler, fp); + testProgrammerError(t, uiFreeEvent(firingEvent), + "attempt to free a uiEvent that still has handlers registered"); uiEventFire(firingEvent, NULL, firingEvent); }