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