mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-24 21:49:10 +00:00
Added SDL_unsetenv()
This commit is contained in:
parent
b854e1fe0b
commit
473feab2a4
9 changed files with 133 additions and 37 deletions
|
@ -624,7 +624,7 @@ static int stdlib_getsetenv(void *arg)
|
|||
text);
|
||||
}
|
||||
|
||||
/* Set value 1 without overwrite */
|
||||
/* Set value 1 with overwrite */
|
||||
overwrite = 1;
|
||||
expected = value1;
|
||||
result = SDL_setenv(name, value1, overwrite);
|
||||
|
@ -643,6 +643,35 @@ static int stdlib_getsetenv(void *arg)
|
|||
text);
|
||||
}
|
||||
|
||||
/* Verify setenv() with empty string vs unsetenv() */
|
||||
result = SDL_setenv("FOO", "1", 1);
|
||||
SDLTest_AssertPass("Call to SDL_setenv('FOO','1', 1)");
|
||||
SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
|
||||
expected = "1";
|
||||
text = SDL_getenv("FOO");
|
||||
SDLTest_AssertPass("Call to SDL_getenv('FOO')");
|
||||
SDLTest_AssertCheck(text && SDL_strcmp(text, expected) == 0, "Verify returned text, expected: %s, got: %s", expected, text);
|
||||
result = SDL_setenv("FOO", "", 1);
|
||||
SDLTest_AssertPass("Call to SDL_setenv('FOO','', 1)");
|
||||
SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
|
||||
expected = "";
|
||||
text = SDL_getenv("FOO");
|
||||
SDLTest_AssertPass("Call to SDL_getenv('FOO')");
|
||||
SDLTest_AssertCheck(text && SDL_strcmp(text, expected) == 0, "Verify returned text, expected: '%s', got: '%s'", expected, text);
|
||||
result = SDL_unsetenv("FOO");
|
||||
SDLTest_AssertPass("Call to SDL_unsetenv('FOO')");
|
||||
SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
|
||||
text = SDL_getenv("FOO");
|
||||
SDLTest_AssertPass("Call to SDL_getenv('FOO')");
|
||||
SDLTest_AssertCheck(text == NULL, "Verify returned text, expected: (null), got: %s", text);
|
||||
result = SDL_setenv("FOO", "0", 0);
|
||||
SDLTest_AssertPass("Call to SDL_setenv('FOO','0', 0)");
|
||||
SDLTest_AssertCheck(result == 0, "Check result, expected: 0, got: %i", result);
|
||||
expected = "0";
|
||||
text = SDL_getenv("FOO");
|
||||
SDLTest_AssertPass("Call to SDL_getenv('FOO')");
|
||||
SDLTest_AssertCheck(text && SDL_strcmp(text, expected) == 0, "Verify returned text, expected: %s, got: %s", expected, text);
|
||||
|
||||
/* Negative cases */
|
||||
for (overwrite = 0; overwrite <= 1; overwrite++) {
|
||||
result = SDL_setenv(NULL, value1, overwrite);
|
||||
|
@ -1026,35 +1055,35 @@ stdlib_overflow(void *arg)
|
|||
/* ================= Test References ================== */
|
||||
|
||||
/* Standard C routine test cases */
|
||||
static const SDLTest_TestCaseReference stdlibTest1 = {
|
||||
static const SDLTest_TestCaseReference stdlibTest_strnlen = {
|
||||
stdlib_strnlen, "stdlib_strnlen", "Call to SDL_strnlen", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest2 = {
|
||||
static const SDLTest_TestCaseReference stdlibTest_strlcpy = {
|
||||
stdlib_strlcpy, "stdlib_strlcpy", "Call to SDL_strlcpy", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest3 = {
|
||||
static const SDLTest_TestCaseReference stdlibTest_strstr = {
|
||||
stdlib_strstr, "stdlib_strstr", "Call to SDL_strstr", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest4 = {
|
||||
static const SDLTest_TestCaseReference stdlibTest_snprintf = {
|
||||
stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest5 = {
|
||||
static const SDLTest_TestCaseReference stdlibTest_swprintf = {
|
||||
stdlib_swprintf, "stdlib_swprintf", "Call to SDL_swprintf", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest6 = {
|
||||
static const SDLTest_TestCaseReference stdlibTest_getsetenv = {
|
||||
stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest7 = {
|
||||
static const SDLTest_TestCaseReference stdlibTest_sscanf = {
|
||||
stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest8 = {
|
||||
static const SDLTest_TestCaseReference stdlibTest_aligned_alloc = {
|
||||
stdlib_aligned_alloc, "stdlib_aligned_alloc", "Call to SDL_aligned_alloc", TEST_ENABLED
|
||||
};
|
||||
|
||||
|
@ -1064,14 +1093,14 @@ static const SDLTest_TestCaseReference stdlibTestOverflow = {
|
|||
|
||||
/* Sequence of Standard C routine test cases */
|
||||
static const SDLTest_TestCaseReference *stdlibTests[] = {
|
||||
&stdlibTest1,
|
||||
&stdlibTest2,
|
||||
&stdlibTest3,
|
||||
&stdlibTest4,
|
||||
&stdlibTest5,
|
||||
&stdlibTest6,
|
||||
&stdlibTest7,
|
||||
&stdlibTest8,
|
||||
&stdlibTest_strnlen,
|
||||
&stdlibTest_strlcpy,
|
||||
&stdlibTest_strstr,
|
||||
&stdlibTest_snprintf,
|
||||
&stdlibTest_swprintf,
|
||||
&stdlibTest_getsetenv,
|
||||
&stdlibTest_sscanf,
|
||||
&stdlibTest_aligned_alloc,
|
||||
&stdlibTestOverflow,
|
||||
NULL
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue