test/testautomation_stdlib.c
changeset 10188 9cf58ba2b2ad
parent 8646 0a20fff4de3c
child 10189 4844b48eb17b
equal deleted inserted replaced
10187:1f0f8c95531d 10188:9cf58ba2b2ad
   251   SDL_free(value2);
   251   SDL_free(value2);
   252     
   252     
   253   return TEST_COMPLETED;
   253   return TEST_COMPLETED;
   254 }
   254 }
   255 
   255 
       
   256 /**
       
   257  * @brief Call to SDL_sscanf
       
   258  */
       
   259 #undef SDL_sscanf
       
   260 int
       
   261 stdlib_sscanf(void *arg)
       
   262 {
       
   263   int output;
       
   264   int result;
       
   265   int expected_output;
       
   266   int expected_result;
       
   267 
       
   268   expected_output = output = 123;
       
   269   expected_result = -1;
       
   270   result = SDL_sscanf("", "%i", &output);
       
   271   SDLTest_AssertPass("Call to SDL_sscanf(\"\", \"%%i\", &output)");
       
   272   SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
       
   273   SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
       
   274 
       
   275   expected_output = output = 123;
       
   276   expected_result = 0;
       
   277   result = SDL_sscanf("a", "%i", &output);
       
   278   SDLTest_AssertPass("Call to SDL_sscanf(\"a\", \"%%i\", &output)");
       
   279   SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
       
   280   SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
       
   281 
       
   282   output = 123;
       
   283   expected_output = 2;
       
   284   expected_result = 1;
       
   285   result = SDL_sscanf("2", "%i", &output);
       
   286   SDLTest_AssertPass("Call to SDL_sscanf(\"2\", \"%%i\", &output)");
       
   287   SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
       
   288   SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
       
   289 
       
   290   return TEST_COMPLETED;
       
   291 }
       
   292 
   256 /* ================= Test References ================== */
   293 /* ================= Test References ================== */
   257 
   294 
   258 /* Standard C routine test cases */
   295 /* Standard C routine test cases */
   259 static const SDLTest_TestCaseReference stdlibTest1 =
   296 static const SDLTest_TestCaseReference stdlibTest1 =
   260         { (SDLTest_TestCaseFp)stdlib_strlcpy, "stdlib_strlcpy", "Call to SDL_strlcpy", TEST_ENABLED };
   297         { (SDLTest_TestCaseFp)stdlib_strlcpy, "stdlib_strlcpy", "Call to SDL_strlcpy", TEST_ENABLED };
   263         { (SDLTest_TestCaseFp)stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED };
   300         { (SDLTest_TestCaseFp)stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED };
   264 
   301 
   265 static const SDLTest_TestCaseReference stdlibTest3 =
   302 static const SDLTest_TestCaseReference stdlibTest3 =
   266         { (SDLTest_TestCaseFp)stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED };
   303         { (SDLTest_TestCaseFp)stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED };
   267 
   304 
       
   305 static const SDLTest_TestCaseReference stdlibTest4 =
       
   306         { (SDLTest_TestCaseFp)stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED };
       
   307 
   268 /* Sequence of Standard C routine test cases */
   308 /* Sequence of Standard C routine test cases */
   269 static const SDLTest_TestCaseReference *stdlibTests[] =  {
   309 static const SDLTest_TestCaseReference *stdlibTests[] =  {
   270     &stdlibTest1, &stdlibTest2, &stdlibTest3, NULL
   310     &stdlibTest1, &stdlibTest2, &stdlibTest3, &stdlibTest4, NULL
   271 };
   311 };
   272 
   312 
   273 /* Timer test suite (global) */
   313 /* Timer test suite (global) */
   274 SDLTest_TestSuiteReference stdlibTestSuite = {
   314 SDLTest_TestSuiteReference stdlibTestSuite = {
   275     "Stdlib",
   315     "Stdlib",