Fixed a bunch of compiler warnings in the test code.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 07 Jan 2017 22:24:45 -0500
changeset 107821de6d4633ee6
parent 10781 7c19d6525105
child 10783 069dbd9e2b71
Fixed a bunch of compiler warnings in the test code.
test/testautomation_clipboard.c
test/testautomation_keyboard.c
test/testautomation_platform.c
test/testautomation_rwops.c
test/testautomation_stdlib.c
     1.1 --- a/test/testautomation_clipboard.c	Sat Jan 07 19:55:29 2017 -0500
     1.2 +++ b/test/testautomation_clipboard.c	Sat Jan 07 22:24:45 2017 -0500
     1.3 @@ -121,7 +121,7 @@
     1.4      SDLTest_AssertCheck(
     1.5          charResult[0] == '\0',
     1.6          "Verify SDL_GetClipboardText returned string with length 0, got length %i",
     1.7 -        SDL_strlen(charResult));
     1.8 +        (int) SDL_strlen(charResult));
     1.9      intResult = SDL_SetClipboardText((const char *)text);
    1.10      SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded");
    1.11      SDLTest_AssertCheck(
     2.1 --- a/test/testautomation_keyboard.c	Sat Jan 07 19:55:29 2017 -0500
     2.2 +++ b/test/testautomation_keyboard.c	Sat Jan 07 22:24:45 2017 -0500
     2.3 @@ -312,7 +312,7 @@
     2.4     /* Get state, cache for later reset */
     2.5     result = SDL_GetModState();
     2.6     SDLTest_AssertPass("Call to SDL_GetModState()");
     2.7 -   SDLTest_AssertCheck(result >=0 && result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result);
     2.8 +   SDLTest_AssertCheck(/*result >= 0 &&*/ result <= allStates, "Verify result from call is valid, expected: 0 <= result <= %i, got: %i", allStates, result);
     2.9     currentState = result;
    2.10  
    2.11     /* Set random state */
     3.1 --- a/test/testautomation_platform.c	Sat Jan 07 19:55:29 2017 -0500
     3.2 +++ b/test/testautomation_platform.c	Sat Jan 07 22:24:45 2017 -0500
     3.3 @@ -309,7 +309,7 @@
     3.4       len = SDL_strlen(lastError);
     3.5       SDLTest_AssertCheck(len == SDL_strlen(testError),
     3.6               "SDL_GetError(): expected message len %i, was len: %i",
     3.7 -             SDL_strlen(testError),
     3.8 +             (int) SDL_strlen(testError),
     3.9               len);
    3.10       SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0,
    3.11               "SDL_GetError(): expected message %s, was message: %s",
    3.12 @@ -347,7 +347,7 @@
    3.13       len = SDL_strlen(lastError);
    3.14       SDLTest_AssertCheck(len == SDL_strlen(testError),
    3.15               "SDL_GetError(): expected message len %i, was len: %i",
    3.16 -             SDL_strlen(testError),
    3.17 +             (int) SDL_strlen(testError),
    3.18               len);
    3.19       SDLTest_AssertCheck(SDL_strcmp(lastError, testError) == 0,
    3.20               "SDL_GetError(): expected message '%s', was message: '%s'",
    3.21 @@ -380,7 +380,7 @@
    3.22     SDLTest_AssertPass("SDL_ClearError()");
    3.23  
    3.24     /* Check for no-op */
    3.25 -   result = SDL_SetError(invalidError);
    3.26 +   result = SDL_SetError("%s", invalidError);
    3.27     SDLTest_AssertPass("SDL_SetError()");
    3.28     SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
    3.29     lastError = (char *)SDL_GetError();
    3.30 @@ -395,12 +395,12 @@
    3.31     }
    3.32  
    3.33     /* Set */
    3.34 -   result = SDL_SetError(probeError);
    3.35 +   result = SDL_SetError("%s", probeError);
    3.36     SDLTest_AssertPass("SDL_SetError('%s')", probeError);
    3.37     SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
    3.38  
    3.39     /* Check for no-op */
    3.40 -   result = SDL_SetError(invalidError);
    3.41 +   result = SDL_SetError("%s", invalidError);
    3.42     SDLTest_AssertPass("SDL_SetError(NULL)");
    3.43     SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
    3.44     lastError = (char *)SDL_GetError();
    3.45 @@ -419,7 +419,7 @@
    3.46     SDLTest_AssertPass("SDL_ClearError()");
    3.47  
    3.48     /* Set and check */
    3.49 -   result = SDL_SetError(probeError);
    3.50 +   result = SDL_SetError("%s", probeError);
    3.51     SDLTest_AssertPass("SDL_SetError()");
    3.52     SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
    3.53     lastError = (char *)SDL_GetError();
    3.54 @@ -430,7 +430,7 @@
    3.55       len = SDL_strlen(lastError);
    3.56       SDLTest_AssertCheck(len == SDL_strlen(probeError),
    3.57               "SDL_GetError(): expected message len %i, was len: %i",
    3.58 -             SDL_strlen(probeError),
    3.59 +             (int) SDL_strlen(probeError),
    3.60               len);
    3.61       SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0,
    3.62               "SDL_GetError(): expected message '%s', was message: '%s'",
     4.1 --- a/test/testautomation_rwops.c	Sat Jan 07 19:55:29 2017 -0500
     4.2 +++ b/test/testautomation_rwops.c	Sat Jan 07 22:24:45 2017 -0500
     4.3 @@ -111,10 +111,10 @@
     4.4     s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1);
     4.5     SDLTest_AssertPass("Call to SDL_RWwrite succeeded");
     4.6     if (write) {
     4.7 -        SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", s);
     4.8 +        SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", (int) s);
     4.9     }
    4.10     else {
    4.11 -        SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", s);
    4.12 +        SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", (int) s);
    4.13     }
    4.14  
    4.15     /* Test seek to random position */
    4.16 @@ -133,8 +133,8 @@
    4.17     SDLTest_AssertCheck(
    4.18         s == (size_t)(sizeof(RWopsHelloWorldTestString)-1),
    4.19         "Verify result from SDL_RWread, expected %i, got %i",
    4.20 -       sizeof(RWopsHelloWorldTestString)-1,
    4.21 -       s);
    4.22 +       (int) (sizeof(RWopsHelloWorldTestString)-1),
    4.23 +       (int) s);
    4.24     SDLTest_AssertCheck(
    4.25         SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0,
    4.26         "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
    4.27 @@ -144,25 +144,25 @@
    4.28     SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded");
    4.29     SDLTest_AssertCheck(
    4.30         i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5),
    4.31 -       "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %"SDL_PRIs64,
    4.32 -       sizeof(RWopsHelloWorldTestString)-5,
    4.33 -       i);
    4.34 +       "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i",
    4.35 +       (int) (sizeof(RWopsHelloWorldTestString)-5),
    4.36 +       (int) i);
    4.37  
    4.38     i = SDL_RWseek( rw, -1, RW_SEEK_END );
    4.39     SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded");
    4.40     SDLTest_AssertCheck(
    4.41         i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2),
    4.42 -       "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %"SDL_PRIs64,
    4.43 -       sizeof(RWopsHelloWorldTestString)-2,
    4.44 -       i);
    4.45 +       "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i",
    4.46 +       (int) (sizeof(RWopsHelloWorldTestString)-2),
    4.47 +       (int) i);
    4.48  
    4.49     /* Invalid whence seek */
    4.50     i = SDL_RWseek( rw, 0, 999 );
    4.51     SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded");
    4.52     SDLTest_AssertCheck(
    4.53         i == (Sint64)(-1),
    4.54 -       "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %"SDL_PRIs64,
    4.55 -       i);
    4.56 +       "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %i",
    4.57 +       (int) i);
    4.58  }
    4.59  
    4.60  /* !
    4.61 @@ -559,8 +559,8 @@
    4.62       SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
    4.63  
    4.64       /* Compare */
    4.65 -     SDLTest_AssertCheck(rv_mem == rv_file, "Verify returned read blocks matches for mem and file reads; got: rv_mem=%d rv_file=%d", rv_mem, rv_file);
    4.66 -     SDLTest_AssertCheck(sv_mem == sv_file, "Verify SEEK_END position matches for mem and file seeks; got: sv_mem=%"SDL_PRIu64" sv_file=%"SDL_PRIu64, sv_mem, sv_file);
    4.67 +     SDLTest_AssertCheck(rv_mem == rv_file, "Verify returned read blocks matches for mem and file reads; got: rv_mem=%d rv_file=%d", (int) rv_mem, (int) rv_file);
    4.68 +     SDLTest_AssertCheck(sv_mem == sv_file, "Verify SEEK_END position matches for mem and file seeks; got: sv_mem=%d sv_file=%d", (int) sv_mem, (int) sv_file);
    4.69       SDLTest_AssertCheck(buffer_mem[slen] == 0, "Verify mem buffer termination; expected: 0, got: %d", buffer_mem[slen]);
    4.70       SDLTest_AssertCheck(buffer_file[slen] == 0, "Verify file buffer termination; expected: 0, got: %d", buffer_file[slen]);
    4.71       SDLTest_AssertCheck(
    4.72 @@ -648,27 +648,27 @@
    4.73       /* Write test data */
    4.74       objectsWritten = SDL_WriteBE16(rw, BE16value);
    4.75       SDLTest_AssertPass("Call to SDL_WriteBE16()");
    4.76 -     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
    4.77 +     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
    4.78       objectsWritten = SDL_WriteBE32(rw, BE32value);
    4.79       SDLTest_AssertPass("Call to SDL_WriteBE32()");
    4.80 -     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
    4.81 +     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
    4.82       objectsWritten = SDL_WriteBE64(rw, BE64value);
    4.83       SDLTest_AssertPass("Call to SDL_WriteBE64()");
    4.84 -     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
    4.85 +     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
    4.86       objectsWritten = SDL_WriteLE16(rw, LE16value);
    4.87       SDLTest_AssertPass("Call to SDL_WriteLE16()");
    4.88 -     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
    4.89 +     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
    4.90       objectsWritten = SDL_WriteLE32(rw, LE32value);
    4.91       SDLTest_AssertPass("Call to SDL_WriteLE32()");
    4.92 -     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
    4.93 +     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
    4.94       objectsWritten = SDL_WriteLE64(rw, LE64value);
    4.95       SDLTest_AssertPass("Call to SDL_WriteLE64()");
    4.96 -     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);
    4.97 +     SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
    4.98  
    4.99       /* Test seek to start */
   4.100       result = SDL_RWseek( rw, 0, RW_SEEK_SET );
   4.101       SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   4.102 -     SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %"SDL_PRIs64, result);
   4.103 +     SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %i", (int) result);
   4.104  
   4.105       /* Read test data */
   4.106       BE16test = SDL_ReadBE16(rw);
     5.1 --- a/test/testautomation_stdlib.c	Sat Jan 07 19:55:29 2017 -0500
     5.2 +++ b/test/testautomation_stdlib.c	Sat Jan 07 22:24:45 2017 -0500
     5.3 @@ -25,13 +25,13 @@
     5.4    expected = "foo";
     5.5    SDLTest_AssertPass("Call to SDL_strlcpy(\"foo\")");
     5.6    SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
     5.7 -  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result);
     5.8 +  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int) SDL_strlen(text), (int) result);
     5.9  
    5.10    result = SDL_strlcpy(text, "foo", 2);
    5.11    expected = "f";
    5.12    SDLTest_AssertPass("Call to SDL_strlcpy(\"foo\") with buffer size 2");
    5.13    SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
    5.14 -  SDLTest_AssertCheck(result == 3, "Check result value, expected: 3, got: %d", result);
    5.15 +  SDLTest_AssertCheck(result == 3, "Check result value, expected: 3, got: %d", (int) result);
    5.16  
    5.17    return TEST_COMPLETED;
    5.18  }
    5.19 @@ -51,7 +51,7 @@
    5.20    expected = "foo";
    5.21    SDLTest_AssertPass("Call to SDL_snprintf(\"%%s\", \"foo\")");
    5.22    SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
    5.23 -  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result);
    5.24 +  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int) SDL_strlen(text), result);
    5.25  
    5.26    result = SDL_snprintf(text, 2, "%s", "foo");
    5.27    expected = "f";
    5.28 @@ -66,49 +66,49 @@
    5.29    expected = "1.000000";
    5.30    SDLTest_AssertPass("Call to SDL_snprintf(\"%%f\", 1.0)");
    5.31    SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
    5.32 -  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result);
    5.33 +  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int) SDL_strlen(text), result);
    5.34  
    5.35    result = SDL_snprintf(text, sizeof(text), "%.f", 1.0);
    5.36    expected = "1";
    5.37    SDLTest_AssertPass("Call to SDL_snprintf(\"%%.f\", 1.0)");
    5.38    SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
    5.39 -  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result);
    5.40 +  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int) SDL_strlen(text), result);
    5.41  
    5.42    result = SDL_snprintf(text, sizeof(text), "%#.f", 1.0);
    5.43    expected = "1.";
    5.44    SDLTest_AssertPass("Call to SDL_snprintf(\"%%#.f\", 1.0)");
    5.45    SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
    5.46 -  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result);
    5.47 +  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int) SDL_strlen(text), result);
    5.48  
    5.49    result = SDL_snprintf(text, sizeof(text), "%f", 1.0 + 1.0 / 3.0);
    5.50    expected = "1.333333";
    5.51    SDLTest_AssertPass("Call to SDL_snprintf(\"%%f\", 1.0 + 1.0 / 3.0)");
    5.52    SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
    5.53 -  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result);
    5.54 +  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int) SDL_strlen(text), result);
    5.55  
    5.56    result = SDL_snprintf(text, sizeof(text), "%+f", 1.0 + 1.0 / 3.0);
    5.57    expected = "+1.333333";
    5.58    SDLTest_AssertPass("Call to SDL_snprintf(\"%%+f\", 1.0 + 1.0 / 3.0)");
    5.59    SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
    5.60 -  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result);
    5.61 +  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int) SDL_strlen(text), result);
    5.62  
    5.63    result = SDL_snprintf(text, sizeof(text), "%.2f", 1.0 + 1.0 / 3.0);
    5.64    expected = "1.33";
    5.65    SDLTest_AssertPass("Call to SDL_snprintf(\"%%.2f\", 1.0 + 1.0 / 3.0)");
    5.66    SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text);
    5.67 -  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result);
    5.68 +  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int) SDL_strlen(text), result);
    5.69  
    5.70    result = SDL_snprintf(text, sizeof(text), "%6.2f", 1.0 + 1.0 / 3.0);
    5.71    expected = "  1.33";
    5.72    SDLTest_AssertPass("Call to SDL_snprintf(\"%%6.2f\", 1.0 + 1.0 / 3.0)");
    5.73    SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text);
    5.74 -  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result);
    5.75 +  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int) SDL_strlen(text), result);
    5.76  
    5.77    result = SDL_snprintf(text, sizeof(text), "%06.2f", 1.0 + 1.0 / 3.0);
    5.78    expected = "001.33";
    5.79    SDLTest_AssertPass("Call to SDL_snprintf(\"%%06.2f\", 1.0 + 1.0 / 3.0)");
    5.80    SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text);
    5.81 -  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result);
    5.82 +  SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int) SDL_strlen(text), result);
    5.83  
    5.84    result = SDL_snprintf(text, 5, "%06.2f", 1.0 + 1.0 / 3.0);
    5.85    expected = "001.";
    5.86 @@ -146,7 +146,7 @@
    5.87      text = SDL_getenv(name);
    5.88      SDLTest_AssertPass("Call to SDL_getenv('%s')", name);
    5.89      if (text != NULL) {
    5.90 -      SDLTest_Log("Expected: NULL, Got: '%s' (%i)", text, SDL_strlen(text));
    5.91 +      SDLTest_Log("Expected: NULL, Got: '%s' (%i)", text, (int) SDL_strlen(text));
    5.92      }
    5.93    } while (text != NULL);
    5.94