/** * @brief Tests opening from memory. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem * http://wiki.libsdl.org/moin.cgi/SDL_RWClose */ int rwops_testConstMem (void) { SDL_RWops *rw; int result; /* Open handle */ rw = SDL_RWFromConstMem( RWopsHelloWorldCompString, sizeof(RWopsHelloWorldCompString)-1 ); SDLTest_AssertPass("Call to SDL_RWFromConstMem() succeeded"); SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromConstMem does not return NULL"); /* Bail out if NULL */ if (rw == NULL) return TEST_ABORTED; /* Check type */ SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY_RO, "Verify RWops type is SDL_RWOPS_MEMORY_RO; expected: %d, got: %d", SDL_RWOPS_MEMORY_RO, rw->type); /* Run generic tests */ _testGenericRWopsValidations( rw, 0 ); /* Close handle */ result = SDL_RWclose(rw); SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); return TEST_COMPLETED; }
/** * @brief Tests opening from memory. * * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWClose */ int rwops_testMem (void) { char mem[sizeof(RWopsHelloWorldTestString)]; SDL_RWops *rw; int result; /* Clear buffer */ SDL_zero(mem); /* Open */ rw = SDL_RWFromMem(mem, sizeof(RWopsHelloWorldTestString)-1); SDLTest_AssertPass("Call to SDL_RWFromMem() succeeded"); SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromMem does not return NULL"); /* Bail out if NULL */ if (rw == NULL) return TEST_ABORTED; /* Check type */ SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY, "Verify RWops type is SDL_RWOPS_MEMORY; expected: %d, got: %d", SDL_RWOPS_MEMORY, rw->type); /* Run generic tests */ _testGenericRWopsValidations(rw, 1); /* Close */ result = SDL_RWclose(rw); SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); return TEST_COMPLETED; }
/** * @brief Tests writing to file handle * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP * http://wiki.libsdl.org/moin.cgi/SDL_RWClose * */ int rwops_testFPWrite(void) { FILE *fp; SDL_RWops *rw; /* Run write tests. */ fp = fopen(RWopsWriteTestFilename, "w+"); SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in write mode is not NULL", RWopsWriteTestFilename); /* Bail out if NULL */ if (fp == NULL) return TEST_ABORTED; /* Open */ rw = SDL_RWFromFP( fp, SDL_TRUE ); SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded"); SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in write mode does not return NULL"); /* Bail out if NULL */ if (rw == NULL) { fclose(fp); return TEST_ABORTED; } /* Run generic tests */ _testGenericRWopsValidations( rw, 1 ); /* Close handle - does fclose() */ SDL_RWclose(rw); SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); return TEST_COMPLETED; }
/** * @brief Tests opening from memory. * * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem * http://wiki.libsdl.org/moin.cgi/SDL_RWClose */ int rwops_testMem (void) { char mem[sizeof(RWopsHelloWorldTestString)]; SDL_RWops *rw; /* Clear buffer */ SDL_zero(mem); /* Open */ rw = SDL_RWFromMem(mem, sizeof(RWopsHelloWorldTestString)-1); SDLTest_AssertPass("Call to SDL_RWFromMem() succeeded"); SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromMem does not return NULL"); /* Bail out if NULL */ if (rw == NULL) return TEST_ABORTED; /* Run generic tests */ _testGenericRWopsValidations(rw, 1); /* Close */ SDL_RWclose(rw); SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); return TEST_COMPLETED; }
/** * @brief Tests reading from file handle * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP * http://wiki.libsdl.org/moin.cgi/SDL_RWClose * */ int rwops_testFPRead(void) { FILE *fp; SDL_RWops *rw; int result; /* Run read tests. */ fp = fopen(RWopsReadTestFilename, "r"); SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in read mode is not NULL", RWopsReadTestFilename); /* Bail out if NULL */ if (fp == NULL) return TEST_ABORTED; /* Open */ rw = SDL_RWFromFP( fp, SDL_TRUE ); SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded"); SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in read mode does not return NULL"); /* Bail out if NULL */ if (rw == NULL) { fclose(fp); return TEST_ABORTED; } /* Check type */ SDLTest_AssertCheck( rw->type == SDL_RWOPS_STDFILE, "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type); /* Run generic tests */ _testGenericRWopsValidations( rw, 0 ); /* Close handle - does fclose() */ result = SDL_RWclose(rw); SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); return TEST_COMPLETED; }
/** * @brief Tests writing from file. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile * http://wiki.libsdl.org/moin.cgi/SDL_RWClose */ int rwops_testFileWrite(void) { SDL_RWops *rw; int result; /* Write test. */ rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+"); SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\") succeeded"); SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL"); /* Bail out if NULL */ if (rw == NULL) return TEST_ABORTED; /* Check type */ #if defined(ANDROID) SDLTest_AssertCheck( rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type); #elif defined(__WIN32__) SDLTest_AssertCheck( rw->type == SDL_RWOPS_WINFILE, "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type); #else SDLTest_AssertCheck( rw->type == SDL_RWOPS_STDFILE, "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type); #endif /* Run generic tests */ _testGenericRWopsValidations( rw, 1 ); /* Close handle */ result = SDL_RWclose(rw); SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result); return TEST_COMPLETED; }
/** * @brief Tests writing from file. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile * http://wiki.libsdl.org/moin.cgi/SDL_RWClose */ int rwops_testFileWrite(void) { SDL_RWops *rw; /* Write test. */ rw = SDL_RWFromFile(RWopsWriteTestFilename, "w+"); SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\") succeeded"); SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL"); // Bail out if NULL if (rw == NULL) return TEST_ABORTED; /* Run generic tests */ _testGenericRWopsValidations( rw, 1 ); /* Close handle */ SDL_RWclose(rw); SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); return TEST_COMPLETED; }
/** * @brief Tests opening from memory. * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem * http://wiki.libsdl.org/moin.cgi/SDL_RWClose */ int rwops_testConstMem (void) { SDL_RWops *rw; /* Open handle */ rw = SDL_RWFromConstMem( RWopsHelloWorldCompString, sizeof(RWopsHelloWorldCompString)-1 ); SDLTest_AssertPass("Call to SDL_RWFromConstMem() succeeded"); SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromConstMem does not return NULL"); /* Bail out if NULL */ if (rw == NULL) return TEST_ABORTED; /* Run generic tests */ _testGenericRWopsValidations( rw, 0 ); /* Close handle */ SDL_RWclose(rw); SDLTest_AssertPass("Call to SDL_RWclose() succeeded"); return TEST_COMPLETED; }