mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-01 17:37:39 +00:00
Added SDL_ResetHint() to reset a hint to the default value
Resolves question of how to clear an override hint raised by @pionere in https://github.com/libsdl-org/SDL/pull/5309
This commit is contained in:
parent
3119d58ff5
commit
d4192850c1
7 changed files with 108 additions and 2 deletions
|
@ -98,8 +98,9 @@ hints_getHint(void *arg)
|
|||
int
|
||||
hints_setHint(void *arg)
|
||||
{
|
||||
const char *testHint = "SDL_AUTOMATED_TEST_HINT";
|
||||
const char *originalValue;
|
||||
const char *value;
|
||||
char *value;
|
||||
const char *testValue;
|
||||
SDL_bool result;
|
||||
int i, j;
|
||||
|
@ -142,7 +143,54 @@ hints_setHint(void *arg)
|
|||
SDL_free((void *)originalValue);
|
||||
}
|
||||
|
||||
SDL_free((void *)value);
|
||||
SDL_free(value);
|
||||
|
||||
/* Set default value in environment */
|
||||
SDL_setenv(testHint, "original", 1);
|
||||
|
||||
SDLTest_AssertPass("Call to SDL_GetHint() after saving and restoring hint");
|
||||
originalValue = SDL_GetHint(testHint);
|
||||
value = (originalValue == NULL) ? NULL : SDL_strdup(originalValue);
|
||||
SDL_SetHint(testHint, "temp");
|
||||
SDL_SetHint(testHint, value);
|
||||
SDL_free(value);
|
||||
testValue = SDL_GetHint(testHint);
|
||||
SDLTest_AssertCheck(
|
||||
testValue && SDL_strcmp(testValue, "original") == 0,
|
||||
"testValue = %s, expected \"original\"",
|
||||
testValue);
|
||||
|
||||
SDLTest_AssertPass("Call to SDL_SetHintWithPriority(NULL, SDL_HINT_DEFAULT)");
|
||||
SDL_SetHintWithPriority(testHint, NULL, SDL_HINT_DEFAULT);
|
||||
testValue = SDL_GetHint(testHint);
|
||||
SDLTest_AssertCheck(
|
||||
testValue && SDL_strcmp(testValue, "original") == 0,
|
||||
"testValue = %s, expected \"original\"",
|
||||
testValue);
|
||||
|
||||
SDLTest_AssertPass("Call to SDL_SetHintWithPriority(\"temp\", SDL_HINT_OVERRIDE)");
|
||||
SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE);
|
||||
testValue = SDL_GetHint(testHint);
|
||||
SDLTest_AssertCheck(
|
||||
testValue && SDL_strcmp(testValue, "temp") == 0,
|
||||
"testValue = %s, expected \"temp\"",
|
||||
testValue);
|
||||
|
||||
SDLTest_AssertPass("Call to SDL_SetHintWithPriority(NULL, SDL_HINT_OVERRIDE)");
|
||||
SDL_SetHintWithPriority(testHint, NULL, SDL_HINT_OVERRIDE);
|
||||
testValue = SDL_GetHint(testHint);
|
||||
SDLTest_AssertCheck(
|
||||
testValue == NULL,
|
||||
"testValue = %s, expected NULL",
|
||||
testValue);
|
||||
|
||||
SDLTest_AssertPass("Call to SDL_ResetHint()");
|
||||
SDL_ResetHint(testHint);
|
||||
testValue = SDL_GetHint(testHint);
|
||||
SDLTest_AssertCheck(
|
||||
testValue && SDL_strcmp(testValue, "original") == 0,
|
||||
"testValue = %s, expected \"original\"",
|
||||
testValue);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue