13 #define _CRT_SECURE_NO_WARNINGS 48 if (handle ==
NULL)
return;
53 SDLTest_AssertCheck(fileLen == writtenLen,
"Verify number of written bytes, expected %i, got %i", (
int) fileLen, (
int) writtenLen);
54 result = fclose(handle);
60 if (handle ==
NULL)
return;
65 SDLTest_AssertCheck(fileLen == writtenLen,
"Verify number of written bytes, expected %i, got %i", (
int) fileLen, (
int) writtenLen);
66 result = fclose(handle);
114 SDLTest_AssertCheck(s == (
size_t)1,
"Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", (
int) s);
117 SDLTest_AssertCheck(s == (
size_t)0,
"Verify result of writing with SDL_RWwrite, expected: 0, got %i", (
int) s);
135 "Verify result from SDL_RWread, expected %i, got %i",
147 "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i",
155 "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i",
164 "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %i",
312 #if defined(__ANDROID__) 316 #elif defined(__WIN32__) 359 #if defined(__ANDROID__) 363 #elif defined(__WIN32__) 521 char buffer_file[27];
533 for (size=5; size<10; size++)
536 buffer_file[slen] = 0;
537 buffer_mem[slen] = 0;
542 rv_mem =
SDL_RWread(rwops_mem, buffer_mem, size, 6);
553 rv_file =
SDL_RWread(rwops_file, buffer_file, size, 6);
555 sv_file =
SDL_RWseek(rwops_file, 0, SEEK_END);
562 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);
563 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);
564 SDLTest_AssertCheck(buffer_mem[slen] == 0,
"Verify mem buffer termination; expected: 0, got: %d", buffer_mem[slen]);
565 SDLTest_AssertCheck(buffer_file[slen] == 0,
"Verify file buffer termination; expected: 0, got: %d", buffer_file[slen]);
567 SDL_strncmp(buffer_mem, RWopsAlphabetString, slen) == 0,
568 "Verify mem buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_mem);
570 SDL_strncmp(buffer_file, RWopsAlphabetString, slen) == 0,
571 "Verify file buffer contain alphabet string; expected: %s, got: %s", RWopsAlphabetString, buffer_file);
592 size_t objectsWritten;
607 for (mode = 0; mode < 3; mode++) {
651 SDLTest_AssertCheck(objectsWritten == 1,
"Validate number of objects written, expected: 1, got: %i", (
int) objectsWritten);
654 SDLTest_AssertCheck(objectsWritten == 1,
"Validate number of objects written, expected: 1, got: %i", (
int) objectsWritten);
657 SDLTest_AssertCheck(objectsWritten == 1,
"Validate number of objects written, expected: 1, got: %i", (
int) objectsWritten);
660 SDLTest_AssertCheck(objectsWritten == 1,
"Validate number of objects written, expected: 1, got: %i", (
int) objectsWritten);
663 SDLTest_AssertCheck(objectsWritten == 1,
"Validate number of objects written, expected: 1, got: %i", (
int) objectsWritten);
666 SDLTest_AssertCheck(objectsWritten == 1,
"Validate number of objects written, expected: 1, got: %i", (
int) objectsWritten);
671 SDLTest_AssertCheck(result == 0,
"Verify result from position 0 with SDL_RWseek, expected 0, got %i", (
int) result);
676 SDLTest_AssertCheck(BE16test == BE16value,
"Validate return value from SDL_ReadBE16, expected: %hu, got: %hu", BE16value, BE16test);
679 SDLTest_AssertCheck(BE32test == BE32value,
"Validate return value from SDL_ReadBE32, expected: %u, got: %u", BE32value, BE32test);
685 SDLTest_AssertCheck(LE16test == LE16value,
"Validate return value from SDL_ReadLE16, expected: %hu, got: %hu", LE16value, LE16test);
688 SDLTest_AssertCheck(LE32test == LE32value,
"Validate return value from SDL_ReadLE32, expected: %u, got: %u", LE32value, LE32test);
691 SDLTest_AssertCheck(LE64test == LE64value,
"Validate return value from SDL_ReadLE64, expected: %"SDL_PRIu64
", got: %"SDL_PRIu64, LE64value, LE64test);
int rwops_testFPWrite(void)
Tests writing to file handle.
SDLTest_TestSuiteReference rwopsTestSuite
static const SDLTest_TestCaseReference rwopsTest10
static const SDLTest_TestCaseReference rwopsTest3
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max)
#define SDL_RWwrite(ctx, ptr, size, n)
const char * RWopsAlphabetFilename
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
static const SDLTest_TestCaseReference * rwopsTests[]
#define SDL_RWOPS_WINFILE
#define SDL_RWread(ctx, ptr, size, n)
#define SDL_RWOPS_UNKNOWN
Uint32 SDLTest_RandomUint32(void)
static const SDLTest_TestCaseReference rwopsTest2
static const SDLTest_TestCaseReference rwopsTest9
static const SDLTest_TestCaseReference rwopsTest4
#define SDL_RWseek(ctx, offset, whence)
int rwops_testParamNegative(void)
int(* SDLTest_TestCaseFp)(void *arg)
static const SDLTest_TestCaseReference rwopsTest1
EGLImageKHR EGLint EGLint * handle
static const char RWopsHelloWorldTestString[]
void RWopsSetUp(void *arg)
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
Uint64 SDLTest_RandomUint64(void)
static const SDLTest_TestCaseReference rwopsTest6
int rwops_testMem(void)
Tests opening from memory.
static const SDLTest_TestCaseReference rwopsTest7
const char * RWopsWriteTestFilename
GLenum GLuint GLenum GLsizei const GLchar * buf
static const char RWopsAlphabetString[]
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
const char * RWopsReadTestFilename
int rwops_testFPRead(void)
Tests reading from file handle.
void RWopsTearDown(void *arg)
#define SDL_RWOPS_STDFILE
#define SDL_RWOPS_MEMORY_RO
int rwops_testConstMem(void)
Tests opening from memory.
Uint16 SDLTest_RandomUint16(void)
static const SDLTest_TestCaseReference rwopsTest5
int rwops_testFileRead(void)
Tests reading from file.
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(1)
Prints given message with a timestamp in the TEST category and INFO priority.
int rwops_testAllocFree(void)
Tests alloc and free RW context.
#define SDL_RWFromConstMem
void _testGenericRWopsValidations(SDL_RWops *rw, int write)
Makes sure parameters work properly. Local helper function.
int rwops_testCompareRWFromMemWithRWFromFile(void)
Compare memory and file reads.
static const char RWopsHelloWorldCompString[]
int rwops_testFileWrite(void)
Tests writing from file.
static const SDLTest_TestCaseReference rwopsTest8
int rwops_testFileWriteReadEndian(void)
Tests writing and reading from file using endian aware functions.
#define SDL_RWOPS_JNIFILE