Added a simple test case for SDL_sscanf() to tests.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Tue, 28 Jun 2016 21:14:11 +0200
changeset 101889cf58ba2b2ad
parent 10187 1f0f8c95531d
child 10189 4844b48eb17b
Added a simple test case for SDL_sscanf() to tests.

It fails on platforms where SDL's custom implementation is used.

Relates to Bugzilla #3341.
test/testautomation_stdlib.c
     1.1 --- a/test/testautomation_stdlib.c	Tue Jun 28 21:08:23 2016 +0200
     1.2 +++ b/test/testautomation_stdlib.c	Tue Jun 28 21:14:11 2016 +0200
     1.3 @@ -253,6 +253,43 @@
     1.4    return TEST_COMPLETED;
     1.5  }
     1.6  
     1.7 +/**
     1.8 + * @brief Call to SDL_sscanf
     1.9 + */
    1.10 +#undef SDL_sscanf
    1.11 +int
    1.12 +stdlib_sscanf(void *arg)
    1.13 +{
    1.14 +  int output;
    1.15 +  int result;
    1.16 +  int expected_output;
    1.17 +  int expected_result;
    1.18 +
    1.19 +  expected_output = output = 123;
    1.20 +  expected_result = -1;
    1.21 +  result = SDL_sscanf("", "%i", &output);
    1.22 +  SDLTest_AssertPass("Call to SDL_sscanf(\"\", \"%%i\", &output)");
    1.23 +  SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
    1.24 +  SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
    1.25 +
    1.26 +  expected_output = output = 123;
    1.27 +  expected_result = 0;
    1.28 +  result = SDL_sscanf("a", "%i", &output);
    1.29 +  SDLTest_AssertPass("Call to SDL_sscanf(\"a\", \"%%i\", &output)");
    1.30 +  SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
    1.31 +  SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
    1.32 +
    1.33 +  output = 123;
    1.34 +  expected_output = 2;
    1.35 +  expected_result = 1;
    1.36 +  result = SDL_sscanf("2", "%i", &output);
    1.37 +  SDLTest_AssertPass("Call to SDL_sscanf(\"2\", \"%%i\", &output)");
    1.38 +  SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
    1.39 +  SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
    1.40 +
    1.41 +  return TEST_COMPLETED;
    1.42 +}
    1.43 +
    1.44  /* ================= Test References ================== */
    1.45  
    1.46  /* Standard C routine test cases */
    1.47 @@ -265,9 +302,12 @@
    1.48  static const SDLTest_TestCaseReference stdlibTest3 =
    1.49          { (SDLTest_TestCaseFp)stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED };
    1.50  
    1.51 +static const SDLTest_TestCaseReference stdlibTest4 =
    1.52 +        { (SDLTest_TestCaseFp)stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED };
    1.53 +
    1.54  /* Sequence of Standard C routine test cases */
    1.55  static const SDLTest_TestCaseReference *stdlibTests[] =  {
    1.56 -    &stdlibTest1, &stdlibTest2, &stdlibTest3, NULL
    1.57 +    &stdlibTest1, &stdlibTest2, &stdlibTest3, &stdlibTest4, NULL
    1.58  };
    1.59  
    1.60  /* Timer test suite (global) */