mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-04 14:49:40 +00:00
Renamed event memory to temporary memory, since it's not just used for events
This commit is contained in:
@@ -178,7 +178,7 @@ static int events_addDelEventWatchWithUserdata(void *arg)
|
||||
/**
|
||||
* Creates and validates temporary event memory
|
||||
*/
|
||||
static int events_eventMemory(void *arg)
|
||||
static int events_temporaryMemory(void *arg)
|
||||
{
|
||||
SDL_Event event;
|
||||
void *mem, *claimed, *tmp;
|
||||
@@ -186,20 +186,20 @@ static int events_eventMemory(void *arg)
|
||||
|
||||
{
|
||||
/* Create and claim event memory */
|
||||
mem = SDL_AllocateEventMemory(1);
|
||||
SDLTest_AssertCheck(mem != NULL, "SDL_AllocateEventMemory()");
|
||||
mem = SDL_AllocateTemporaryMemory(1);
|
||||
SDLTest_AssertCheck(mem != NULL, "SDL_AllocateTemporaryMemory()");
|
||||
*(char *)mem = '1';
|
||||
|
||||
claimed = SDL_ClaimEventMemory(mem);
|
||||
SDLTest_AssertCheck(claimed != NULL, "SDL_ClaimEventMemory() returned a valid pointer");
|
||||
claimed = SDL_ClaimTemporaryMemory(mem);
|
||||
SDLTest_AssertCheck(claimed != NULL, "SDL_ClaimTemporaryMemory() returned a valid pointer");
|
||||
|
||||
/* Verify that we can't claim it again */
|
||||
tmp = SDL_ClaimEventMemory(mem);
|
||||
SDLTest_AssertCheck(tmp == NULL, "SDL_ClaimEventMemory() can't claim memory twice");
|
||||
tmp = SDL_ClaimTemporaryMemory(mem);
|
||||
SDLTest_AssertCheck(tmp == NULL, "SDL_ClaimTemporaryMemory() can't claim memory twice");
|
||||
|
||||
/* Verify that freeing the original pointer does nothing */
|
||||
SDL_FreeEventMemory(mem);
|
||||
SDLTest_AssertCheck(*(char *)mem == '1', "SDL_FreeEventMemory() on claimed memory has no effect");
|
||||
SDL_FreeTemporaryMemory(mem);
|
||||
SDLTest_AssertCheck(*(char *)mem == '1', "SDL_FreeTemporaryMemory() on claimed memory has no effect");
|
||||
|
||||
/* Clean up */
|
||||
SDL_free(claimed);
|
||||
@@ -207,19 +207,19 @@ static int events_eventMemory(void *arg)
|
||||
|
||||
{
|
||||
/* Create and free event memory */
|
||||
mem = SDL_AllocateEventMemory(1);
|
||||
SDLTest_AssertCheck(mem != NULL, "SDL_AllocateEventMemory()");
|
||||
mem = SDL_AllocateTemporaryMemory(1);
|
||||
SDLTest_AssertCheck(mem != NULL, "SDL_AllocateTemporaryMemory()");
|
||||
*(char *)mem = '1';
|
||||
|
||||
SDL_FreeEventMemory(mem);
|
||||
claimed = SDL_ClaimEventMemory(mem);
|
||||
SDLTest_AssertCheck(claimed == NULL, "SDL_ClaimEventMemory() can't claim memory after it's been freed");
|
||||
SDL_FreeTemporaryMemory(mem);
|
||||
claimed = SDL_ClaimTemporaryMemory(mem);
|
||||
SDLTest_AssertCheck(claimed == NULL, "SDL_ClaimTemporaryMemory() can't claim memory after it's been freed");
|
||||
}
|
||||
|
||||
{
|
||||
/* Create event memory and queue it */
|
||||
mem = SDL_AllocateEventMemory(1);
|
||||
SDLTest_AssertCheck(mem != NULL, "SDL_AllocateEventMemory()");
|
||||
mem = SDL_AllocateTemporaryMemory(1);
|
||||
SDLTest_AssertCheck(mem != NULL, "SDL_AllocateTemporaryMemory()");
|
||||
*(char *)mem = '2';
|
||||
|
||||
SDL_zero(event);
|
||||
@@ -228,8 +228,8 @@ static int events_eventMemory(void *arg)
|
||||
SDL_PushEvent(&event);
|
||||
|
||||
/* Verify that we can't claim the memory once it's on the queue */
|
||||
claimed = SDL_ClaimEventMemory(mem);
|
||||
SDLTest_AssertCheck(claimed == NULL, "SDL_ClaimEventMemory() can't claim memory on the event queue");
|
||||
claimed = SDL_ClaimTemporaryMemory(mem);
|
||||
SDLTest_AssertCheck(claimed == NULL, "SDL_ClaimTemporaryMemory() can't claim memory on the event queue");
|
||||
|
||||
/* Get the event and verify the memory is valid */
|
||||
found = SDL_FALSE;
|
||||
@@ -241,8 +241,8 @@ static int events_eventMemory(void *arg)
|
||||
SDLTest_AssertCheck(found, "SDL_PollEvent() returned queued event");
|
||||
|
||||
/* Verify that we can claim the memory now that we've dequeued it */
|
||||
claimed = SDL_ClaimEventMemory(mem);
|
||||
SDLTest_AssertCheck(claimed != NULL, "SDL_ClaimEventMemory() can claim memory after dequeuing event");
|
||||
claimed = SDL_ClaimTemporaryMemory(mem);
|
||||
SDLTest_AssertCheck(claimed != NULL, "SDL_ClaimTemporaryMemory() can claim memory after dequeuing event");
|
||||
|
||||
/* Clean up */
|
||||
SDL_free(claimed);
|
||||
@@ -250,8 +250,8 @@ static int events_eventMemory(void *arg)
|
||||
|
||||
{
|
||||
/* Create event memory and queue it */
|
||||
mem = SDL_AllocateEventMemory(1);
|
||||
SDLTest_AssertCheck(mem != NULL, "SDL_AllocateEventMemory()");
|
||||
mem = SDL_AllocateTemporaryMemory(1);
|
||||
SDLTest_AssertCheck(mem != NULL, "SDL_AllocateTemporaryMemory()");
|
||||
*(char *)mem = '3';
|
||||
|
||||
SDL_zero(event);
|
||||
@@ -270,8 +270,8 @@ static int events_eventMemory(void *arg)
|
||||
|
||||
/* Verify that pumping the event loop frees event memory */
|
||||
SDL_PumpEvents();
|
||||
claimed = SDL_ClaimEventMemory(mem);
|
||||
SDLTest_AssertCheck(claimed == NULL, "SDL_ClaimEventMemory() can't claim memory after pumping the event loop");
|
||||
claimed = SDL_ClaimTemporaryMemory(mem);
|
||||
SDLTest_AssertCheck(claimed == NULL, "SDL_ClaimTemporaryMemory() can't claim memory after pumping the event loop");
|
||||
}
|
||||
|
||||
return TEST_COMPLETED;
|
||||
@@ -292,13 +292,13 @@ static const SDLTest_TestCaseReference eventsTest3 = {
|
||||
(SDLTest_TestCaseFp)events_addDelEventWatchWithUserdata, "events_addDelEventWatchWithUserdata", "Adds and deletes an event watch function with userdata", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference eventsTestEventMemory = {
|
||||
(SDLTest_TestCaseFp)events_eventMemory, "events_eventMemory", "Creates and validates temporary event memory", TEST_ENABLED
|
||||
static const SDLTest_TestCaseReference eventsTestTemporaryMemory = {
|
||||
(SDLTest_TestCaseFp)events_temporaryMemory, "events_temporaryMemory", "Creates and validates temporary event memory", TEST_ENABLED
|
||||
};
|
||||
|
||||
/* Sequence of Events test cases */
|
||||
static const SDLTest_TestCaseReference *eventsTests[] = {
|
||||
&eventsTest1, &eventsTest2, &eventsTest3, &eventsTestEventMemory, NULL
|
||||
&eventsTest1, &eventsTest2, &eventsTest3, &eventsTestTemporaryMemory, NULL
|
||||
};
|
||||
|
||||
/* Events test suite (global) */
|
||||
|
||||
Reference in New Issue
Block a user