test/testautomation_rwops.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Tue, 12 Mar 2013 09:10:37 -0700
changeset 6996 bc0fd5bced25
parent 6821 f36771112651
child 6999 681820ca0e78
permissions -rw-r--r--
Fix bug 1560 - SDL_RWFromConstMem write operation returns -1 but should return 0.
     1 
     2 /**
     3  * Automated SDL_RWops test.
     4  *
     5  * Original code written by Edgar Simo "bobbens"
     6  * Ported by Markus Kauppila (markus.kauppila@gmail.com)
     7  * Updated and extended for SDL_test by aschiffler at ferzkopp dot net
     8  *
     9  * Released under Public Domain.
    10  */
    11 
    12 /* quiet windows compiler warnings */
    13 #define _CRT_SECURE_NO_WARNINGS
    14 
    15 #include <stdio.h>
    16 
    17 #include "SDL.h"
    18 #include "SDL_test.h"
    19 
    20 /* ================= Test Case Implementation ================== */
    21 
    22 const char* RWopsReadTestFilename = "rwops_read";
    23 const char* RWopsWriteTestFilename = "rwops_write";
    24 
    25 static const char RWopsHelloWorldTestString[] = "Hello World!";
    26 static const char RWopsHelloWorldCompString[] = "Hello World!";
    27 
    28 /* Fixture */
    29 
    30 void
    31 RWopsSetUp(void *arg)
    32 {
    33 	int fileLen = SDL_strlen(RWopsHelloWorldTestString);
    34 	FILE *handle;
    35 	int writtenLen;
    36 	int result;
    37 
    38 	/* Clean up from previous runs (if any); ignore errors */
    39 	remove(RWopsReadTestFilename);
    40 	remove(RWopsWriteTestFilename);
    41 
    42 	/* Create a test file */
    43 	handle = fopen(RWopsReadTestFilename, "w");
    44 	SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename);
    45         if (handle == NULL) return;
    46 
    47 	/* Write some known test into it */
    48 	writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle);
    49 	SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen);
    50 	result = fclose(handle);
    51 	SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
    52 
    53 	SDLTest_AssertPass("Creation of test file completed");
    54 }
    55 
    56 void
    57 RWopsTearDown(void *arg)
    58 {
    59 	int result;
    60 	
    61 	/* Remove the created files to clean up; ignore errors for write filename */
    62 	result = remove(RWopsReadTestFilename);
    63 	SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result);
    64 	remove(RWopsWriteTestFilename);
    65 
    66 	SDLTest_AssertPass("Cleanup of test files completed");
    67 }
    68 
    69 /**
    70  * @brief Makes sure parameters work properly. Local helper function.
    71  *
    72  * \sa
    73  * http://wiki.libsdl.org/moin.cgi/SDL_RWseek
    74  * http://wiki.libsdl.org/moin.cgi/SDL_RWread
    75  */
    76 void 
    77 _testGenericRWopsValidations(SDL_RWops *rw, int write)
    78 {
    79    char buf[sizeof(RWopsHelloWorldTestString)];
    80    Sint64 i;
    81    size_t s;
    82    int seekPos = SDLTest_RandomIntegerInRange(4, 8);
    83 
    84    /* Clear buffer */
    85    SDL_zero(buf);
    86 
    87    /* Set to start. */
    88    i = SDL_RWseek(rw, 0, RW_SEEK_SET );
    89    SDLTest_AssertPass("Call to SDL_RWseek succeeded");
    90    SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %i", i);
    91 
    92    /* Test write. */
    93    s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1, 1);
    94    SDLTest_AssertPass("Call to SDL_RWwrite succeeded");
    95    if (write) {
    96 		SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", s);
    97    }
    98    else {
    99 		SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", s);
   100    }
   101 
   102    /* Test seek to random position */
   103    i = SDL_RWseek( rw, seekPos, RW_SEEK_SET );
   104    SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   105    SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %i", seekPos, seekPos, i);
   106 
   107    /* Test seek back to start */
   108    i = SDL_RWseek(rw, 0, RW_SEEK_SET );
   109    SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   110    SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %i", i);
   111 
   112    /* Test read */
   113    s = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 );
   114    SDLTest_AssertPass("Call to SDL_RWread succeeded");
   115    SDLTest_AssertCheck(
   116 	   s == (size_t)(sizeof(RWopsHelloWorldTestString)-1), 
   117 	   "Verify result from SDL_RWread, expected %i, got %i",
   118 	   sizeof(RWopsHelloWorldTestString)-1,
   119 	   s);
   120    SDLTest_AssertCheck(
   121 	   SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString)-1 ) == 0, 
   122 	   "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
   123 
   124    /* More seek tests. */
   125    i = SDL_RWseek( rw, -4, RW_SEEK_CUR );
   126    SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded");
   127    SDLTest_AssertCheck(
   128 	   i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5), 
   129 	   "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i",
   130 	   sizeof(RWopsHelloWorldTestString)-5,
   131 	   i);
   132 
   133    i = SDL_RWseek( rw, -1, RW_SEEK_END );
   134    SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded");
   135    SDLTest_AssertCheck(
   136 	   i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2), 
   137 	   "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i",
   138 	   sizeof(RWopsHelloWorldTestString)-2,
   139 	   i);
   140 }
   141 
   142 /*!
   143  * Negative test for SDL_RWFromFile parameters
   144  *
   145  * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
   146  *
   147  */
   148 int
   149 rwops_testParamNegative (void)
   150 {
   151    SDL_RWops *rwops;
   152 
   153    /* These should all fail. */
   154    rwops = SDL_RWFromFile(NULL, NULL);
   155    SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, NULL) succeeded");
   156    SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, NULL) returns NULL");
   157 
   158    rwops = SDL_RWFromFile(NULL, "ab+");
   159    SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"ab+\") succeeded");
   160    SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"ab+\") returns NULL");
   161 
   162    rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj");
   163    SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"sldfkjsldkfj\") succeeded");
   164    SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"sldfkjsldkfj\") returns NULL");
   165 
   166    rwops = SDL_RWFromFile("something", "");
   167    SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", \"\") succeeded");
   168    SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", \"\") returns NULL");
   169 
   170    rwops = SDL_RWFromFile("something", NULL);
   171    SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", NULL) succeeded");
   172    SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", NULL) returns NULL");
   173 
   174    return TEST_COMPLETED;
   175 }
   176 
   177 /**
   178  * @brief Tests opening from memory.
   179  *
   180  * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem
   181  * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
   182  */
   183 int
   184 rwops_testMem (void)
   185 {
   186    char mem[sizeof(RWopsHelloWorldTestString)];
   187    SDL_RWops *rw;
   188 
   189    /* Clear buffer */
   190    SDL_zero(mem);
   191 
   192    /* Open */
   193    rw = SDL_RWFromMem(mem, sizeof(RWopsHelloWorldTestString)-1);
   194    SDLTest_AssertPass("Call to SDL_RWFromMem() succeeded");
   195    SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromMem does not return NULL");
   196 
   197    /* Bail out if NULL */
   198    if (rw == NULL) return TEST_ABORTED;
   199 
   200    /* Run generic tests */
   201    _testGenericRWopsValidations(rw, 1);
   202 
   203    /* Close */
   204    SDL_RWclose(rw);
   205    SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   206 
   207    return TEST_COMPLETED;
   208 }
   209 
   210 
   211 /**
   212  * @brief Tests opening from memory.
   213  *
   214  * \sa
   215  * http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem
   216  * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
   217  */
   218 int 
   219 rwops_testConstMem (void)
   220 {
   221    SDL_RWops *rw;
   222 
   223    /* Open handle */
   224    rw = SDL_RWFromConstMem( RWopsHelloWorldCompString, sizeof(RWopsHelloWorldCompString)-1 );
   225    SDLTest_AssertPass("Call to SDL_RWFromConstMem() succeeded");
   226    SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromConstMem does not return NULL");
   227 
   228    /* Bail out if NULL */
   229    if (rw == NULL) return TEST_ABORTED;
   230 
   231    /* Run generic tests */
   232    _testGenericRWopsValidations( rw, 0 );
   233 
   234    /* Close handle */
   235    SDL_RWclose(rw);
   236    SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   237 
   238   return TEST_COMPLETED;
   239 }
   240 
   241 
   242 /**
   243  * @brief Tests reading from file.
   244  *
   245  * \sa
   246  * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
   247  * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
   248  */
   249 int
   250 rwops_testFileRead(void)
   251 {
   252    SDL_RWops *rw;
   253 
   254    /* Read test. */
   255    rw = SDL_RWFromFile(RWopsReadTestFilename, "r");
   256    SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"r\") succeeded");
   257    SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in read mode does not return NULL");
   258 
   259    // Bail out if NULL
   260    if (rw == NULL) return TEST_ABORTED;
   261 
   262    /* Run generic tests */
   263    _testGenericRWopsValidations( rw, 0 );
   264 
   265    /* Close handle */
   266    SDL_RWclose(rw);
   267    SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   268 
   269    return TEST_COMPLETED;
   270 }
   271 
   272 /**
   273  * @brief Tests writing from file.
   274  *
   275  * \sa
   276  * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
   277  * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
   278  */
   279 int
   280 rwops_testFileWrite(void)
   281 {
   282    SDL_RWops *rw;
   283 
   284    /* Write test. */
   285    rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+");
   286    SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\") succeeded");
   287    SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL");
   288 
   289    // Bail out if NULL
   290    if (rw == NULL) return TEST_ABORTED;
   291 
   292    /* Run generic tests */
   293    _testGenericRWopsValidations( rw, 1 );
   294 
   295    /* Close handle */
   296    SDL_RWclose(rw);
   297    SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   298 
   299    return TEST_COMPLETED;
   300 }
   301 
   302 
   303 /**
   304  * @brief Tests reading from file handle
   305  *
   306  * \sa
   307  * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
   308  * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
   309  *
   310  */
   311 int
   312 rwops_testFPRead(void)
   313 {
   314    FILE *fp;
   315    SDL_RWops *rw;
   316 
   317    /* Run read tests. */
   318    fp = fopen(RWopsReadTestFilename, "r");
   319    SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in read mode is not NULL", RWopsReadTestFilename);
   320 
   321    /* Bail out if NULL */
   322    if (fp == NULL) return TEST_ABORTED;
   323 
   324    /* Open */
   325    rw = SDL_RWFromFP( fp, SDL_TRUE );
   326    SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded");
   327    SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in read mode does not return NULL");
   328 
   329    /* Bail out if NULL */
   330    if (rw == NULL) {
   331      fclose(fp);
   332      return TEST_ABORTED;
   333    }
   334 
   335    /* Run generic tests */
   336    _testGenericRWopsValidations( rw, 0 );
   337 
   338    /* Close handle - does fclose() */
   339    SDL_RWclose(rw);
   340    SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   341 
   342    return TEST_COMPLETED;
   343 }
   344 
   345 
   346 /**
   347  * @brief Tests writing to file handle
   348  *
   349  * \sa
   350  * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP
   351  * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
   352  *
   353  */
   354 int
   355 rwops_testFPWrite(void)
   356 {
   357    FILE *fp;
   358    SDL_RWops *rw;
   359 
   360    /* Run write tests. */
   361    fp = fopen(RWopsWriteTestFilename, "w+");
   362    SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in write mode is not NULL", RWopsWriteTestFilename);
   363 
   364    /* Bail out if NULL */
   365    if (fp == NULL) return TEST_ABORTED;
   366 
   367    /* Open */
   368    rw = SDL_RWFromFP( fp, SDL_TRUE );
   369    SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded");
   370    SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in write mode does not return NULL");
   371 
   372    /* Bail out if NULL */
   373    if (rw == NULL) {
   374      fclose(fp);
   375      return TEST_ABORTED;
   376    }
   377 
   378    /* Run generic tests */
   379    _testGenericRWopsValidations( rw, 1 );
   380 
   381    /* Close handle - does fclose() */
   382    SDL_RWclose(rw);
   383    SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   384 
   385    return TEST_COMPLETED;
   386 }
   387 
   388 /**
   389  * @brief Tests alloc and free RW context.
   390  *
   391  * \sa http://wiki.libsdl.org/moin.cgi/SDL_AllocRW
   392  * \sa http://wiki.libsdl.org/moin.cgi/SDL_FreeRW
   393  */
   394 int
   395 rwops_testAllocFree (void)
   396 {
   397    /* Allocate context */
   398    SDL_RWops *rw = SDL_AllocRW();
   399    SDLTest_AssertPass("Call to SDL_AllocRW() succeeded");
   400    SDLTest_AssertCheck(rw != NULL, "Validate result from SDL_AllocRW() is not NULL");
   401    if (rw==NULL) return TEST_ABORTED;
   402           
   403    /* Free context again */
   404    SDL_FreeRW(rw);
   405    SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
   406 
   407    return TEST_COMPLETED;
   408 }
   409 
   410 /**
   411  * @brief Tests writing and reading from file using endian aware functions.
   412  *
   413  * \sa
   414  * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile
   415  * http://wiki.libsdl.org/moin.cgi/SDL_RWClose
   416  * http://wiki.libsdl.org/moin.cgi/SDL_ReadBE16
   417  * http://wiki.libsdl.org/moin.cgi/SDL_WriteBE16
   418  */
   419 int
   420 rwops_testFileWriteReadEndian(void)
   421 {
   422    SDL_RWops *rw;
   423    Sint64 result;
   424    int mode;
   425    size_t objectsWritten;
   426    Uint16 BE16value;
   427    Uint32 BE32value;
   428    Uint64 BE64value;
   429    Uint16 LE16value;
   430    Uint32 LE32value;
   431    Uint64 LE64value;
   432    Uint16 BE16test;
   433    Uint32 BE32test;
   434    Uint64 BE64test;
   435    Uint16 LE16test;
   436    Uint32 LE32test;
   437    Uint64 LE64test;
   438 
   439    for (mode = 0; mode < 3; mode++) {
   440    
   441      /* Create test data */
   442      switch (mode) {
   443        case 0:
   444         SDLTest_Log("All 0 values");
   445         BE16value = 0;
   446         BE32value = 0;
   447         BE64value = 0;
   448         LE16value = 0;
   449         LE32value = 0;
   450         LE64value = 0;
   451         break;
   452        case 1:
   453         SDLTest_Log("All 1 values");
   454         BE16value = 1;
   455         BE32value = 1;
   456         BE64value = 1;
   457         LE16value = 1;
   458         LE32value = 1;
   459         LE64value = 1;
   460         break;
   461        case 2:
   462         SDLTest_Log("Random values");
   463         BE16value = SDLTest_RandomUint16();
   464         BE32value = SDLTest_RandomUint32();
   465         BE64value = SDLTest_RandomUint64();
   466         LE16value = SDLTest_RandomUint16();
   467         LE32value = SDLTest_RandomUint32();
   468         LE64value = SDLTest_RandomUint64();
   469         break;
   470      }
   471    
   472      /* Write test. */
   473      rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+");
   474      SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\")");
   475      SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL");
   476 
   477      // Bail out if NULL
   478      if (rw == NULL) return TEST_ABORTED;
   479 
   480      /* Write test data */
   481      objectsWritten = SDL_WriteBE16(rw, BE16value);
   482      SDLTest_AssertPass("Call to SDL_WriteBE16");
   483      SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);   
   484      objectsWritten = SDL_WriteBE32(rw, BE32value);
   485      SDLTest_AssertPass("Call to SDL_WriteBE32");
   486      SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);   
   487      objectsWritten = SDL_WriteBE64(rw, BE64value);
   488      SDLTest_AssertPass("Call to SDL_WriteBE64");
   489      SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);   
   490      objectsWritten = SDL_WriteLE16(rw, LE16value);
   491      SDLTest_AssertPass("Call to SDL_WriteLE16");
   492      SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);   
   493      objectsWritten = SDL_WriteLE32(rw, LE32value);
   494      SDLTest_AssertPass("Call to SDL_WriteLE32");
   495      SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);   
   496      objectsWritten = SDL_WriteLE64(rw, LE64value);
   497      SDLTest_AssertPass("Call to SDL_WriteLE64");
   498      SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", objectsWritten);   
   499 
   500      /* Test seek to start */
   501      result = SDL_RWseek( rw, 0, RW_SEEK_SET );
   502      SDLTest_AssertPass("Call to SDL_RWseek succeeded");
   503      SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %i", result);
   504 
   505      /* Read test data */
   506      BE16test = SDL_ReadBE16(rw);
   507      SDLTest_AssertPass("Call to SDL_ReadBE16");
   508      SDLTest_AssertCheck(BE16test == BE16value, "Validate return value from SDL_ReadBE16, expected: %hu, got: %hu", BE16value, BE16test);
   509      BE32test = SDL_ReadBE32(rw);
   510      SDLTest_AssertPass("Call to SDL_ReadBE32");
   511      SDLTest_AssertCheck(BE32test == BE32value, "Validate return value from SDL_ReadBE32, expected: %u, got: %u", BE32value, BE32test);   
   512      BE64test = SDL_ReadBE64(rw);
   513      SDLTest_AssertPass("Call to SDL_ReadBE64");
   514      SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %llu, got: %llu", BE64value, BE64test);   
   515      LE16test = SDL_ReadLE16(rw);
   516      SDLTest_AssertPass("Call to SDL_ReadLE16");
   517      SDLTest_AssertCheck(LE16test == LE16value, "Validate return value from SDL_ReadLE16, expected: %hu, got: %hu", LE16value, LE16test);
   518      LE32test = SDL_ReadLE32(rw);
   519      SDLTest_AssertPass("Call to SDL_ReadLE32");
   520      SDLTest_AssertCheck(LE32test == LE32value, "Validate return value from SDL_ReadLE32, expected: %u, got: %u", LE32value, LE32test);   
   521      LE64test = SDL_ReadLE64(rw);
   522      SDLTest_AssertPass("Call to SDL_ReadLE64");
   523      SDLTest_AssertCheck(LE64test == LE64value, "Validate return value from SDL_ReadLE64, expected: %llu, got: %llu", LE64value, LE64test);
   524 
   525      /* Close handle */
   526      SDL_RWclose(rw);
   527      SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
   528    
   529    }
   530 
   531    return TEST_COMPLETED;
   532 }
   533 
   534 
   535 /* ================= Test References ================== */
   536 
   537 /* RWops test cases */
   538 static const SDLTest_TestCaseReference rwopsTest1 =
   539 		{ (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED };
   540 
   541 static const SDLTest_TestCaseReference rwopsTest2 =
   542 		{ (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED };
   543 
   544 static const SDLTest_TestCaseReference rwopsTest3 =
   545 		{ (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED };
   546 
   547 static const SDLTest_TestCaseReference rwopsTest4 =
   548 		{ (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED };
   549 
   550 static const SDLTest_TestCaseReference rwopsTest5 =
   551 		{ (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED };
   552 
   553 static const SDLTest_TestCaseReference rwopsTest6 =
   554 		{ (SDLTest_TestCaseFp)rwops_testFPRead, "rwops_testFPRead", "Test reading from file pointer", TEST_ENABLED };
   555 
   556 static const SDLTest_TestCaseReference rwopsTest7 =
   557 		{ (SDLTest_TestCaseFp)rwops_testFPWrite, "rwops_testFPWrite", "Test writing to file pointer", TEST_ENABLED };
   558 
   559 static const SDLTest_TestCaseReference rwopsTest8 =
   560 		{ (SDLTest_TestCaseFp)rwops_testAllocFree, "rwops_testAllocFree", "Test alloc and free of RW context", TEST_ENABLED };
   561 
   562 static const SDLTest_TestCaseReference rwopsTest9 =
   563 		{ (SDLTest_TestCaseFp)rwops_testFileWriteReadEndian, "rwops_testFileWriteReadEndian", "Test writing and reading via the Endian aware functions", TEST_ENABLED };
   564 
   565 /* Sequence of RWops test cases */
   566 static const SDLTest_TestCaseReference *rwopsTests[] =  {
   567 	&rwopsTest1, &rwopsTest2, &rwopsTest3, &rwopsTest4, &rwopsTest5, &rwopsTest6, 
   568 	&rwopsTest7, &rwopsTest8, &rwopsTest9, NULL
   569 };
   570 
   571 /* RWops test suite (global) */
   572 SDLTest_TestSuiteReference rwopsTestSuite = {
   573 	"RWops",
   574 	RWopsSetUp,
   575 	rwopsTests,
   576 	RWopsTearDown
   577 };