summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/SDL2/test/testautomation_stdlib.c
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2016-11-16 16:26:13 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2016-11-16 16:28:01 +0100
commit47a05778bff9388fc6c479461dd3804c79d7b539 (patch)
treebb3d4dc8df676b8aa478339b3fd0cd305dc4ac4d /3rdparty/SDL2/test/testautomation_stdlib.c
parente61b392edfbfe5b9d70908c087632da915a3abd8 (diff)
Updated SDL2 to 2.0.5 (nw)
Diffstat (limited to '3rdparty/SDL2/test/testautomation_stdlib.c')
-rw-r--r--3rdparty/SDL2/test/testautomation_stdlib.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/3rdparty/SDL2/test/testautomation_stdlib.c b/3rdparty/SDL2/test/testautomation_stdlib.c
index 89245fdcb60..b541995f59b 100644
--- a/3rdparty/SDL2/test/testautomation_stdlib.c
+++ b/3rdparty/SDL2/test/testautomation_stdlib.c
@@ -253,6 +253,43 @@ stdlib_getsetenv(void *arg)
return TEST_COMPLETED;
}
+/**
+ * @brief Call to SDL_sscanf
+ */
+#undef SDL_sscanf
+int
+stdlib_sscanf(void *arg)
+{
+ int output;
+ int result;
+ int expected_output;
+ int expected_result;
+
+ expected_output = output = 123;
+ expected_result = -1;
+ result = SDL_sscanf("", "%i", &output);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"\", \"%%i\", &output)");
+ SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ expected_output = output = 123;
+ expected_result = 0;
+ result = SDL_sscanf("a", "%i", &output);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"a\", \"%%i\", &output)");
+ SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ output = 123;
+ expected_output = 2;
+ expected_result = 1;
+ result = SDL_sscanf("2", "%i", &output);
+ SDLTest_AssertPass("Call to SDL_sscanf(\"2\", \"%%i\", &output)");
+ SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
+ SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
+
+ return TEST_COMPLETED;
+}
+
/* ================= Test References ================== */
/* Standard C routine test cases */
@@ -265,12 +302,15 @@ static const SDLTest_TestCaseReference stdlibTest2 =
static const SDLTest_TestCaseReference stdlibTest3 =
{ (SDLTest_TestCaseFp)stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED };
+static const SDLTest_TestCaseReference stdlibTest4 =
+ { (SDLTest_TestCaseFp)stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED };
+
/* Sequence of Standard C routine test cases */
static const SDLTest_TestCaseReference *stdlibTests[] = {
- &stdlibTest1, &stdlibTest2, &stdlibTest3, NULL
+ &stdlibTest1, &stdlibTest2, &stdlibTest3, &stdlibTest4, NULL
};
-/* Timer test suite (global) */
+/* Standard C routine test suite (global) */
SDLTest_TestSuiteReference stdlibTestSuite = {
"Stdlib",
NULL,