SDL  2.0
testautomation_rwops.c File Reference
#include <stdio.h>
#include "SDL.h"
#include "SDL_test.h"
+ Include dependency graph for testautomation_rwops.c:

Go to the source code of this file.

Macros

#define _CRT_SECURE_NO_WARNINGS
 

Functions

void RWopsSetUp (void *arg)
 
void RWopsTearDown (void *arg)
 
void _testGenericRWopsValidations (SDL_RWops *rw, int write)
 Makes sure parameters work properly. Local helper function. More...
 
int rwops_testParamNegative (void)
 
int rwops_testMem (void)
 Tests opening from memory. More...
 
int rwops_testConstMem (void)
 Tests opening from memory. More...
 
int rwops_testFileRead (void)
 Tests reading from file. More...
 
int rwops_testFileWrite (void)
 Tests writing from file. More...
 
int rwops_testFPRead (void)
 Tests reading from file handle. More...
 
int rwops_testFPWrite (void)
 Tests writing to file handle. More...
 
int rwops_testAllocFree (void)
 Tests alloc and free RW context. More...
 
int rwops_testCompareRWFromMemWithRWFromFile (void)
 Compare memory and file reads. More...
 
int rwops_testFileWriteReadEndian (void)
 Tests writing and reading from file using endian aware functions. More...
 

Variables

const char * RWopsReadTestFilename = "rwops_read"
 
const char * RWopsWriteTestFilename = "rwops_write"
 
const char * RWopsAlphabetFilename = "rwops_alphabet"
 
static const char RWopsHelloWorldTestString [] = "Hello World!"
 
static const char RWopsHelloWorldCompString [] = "Hello World!"
 
static const char RWopsAlphabetString [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 
static const SDLTest_TestCaseReference rwopsTest1
 
static const SDLTest_TestCaseReference rwopsTest2
 
static const SDLTest_TestCaseReference rwopsTest3
 
static const SDLTest_TestCaseReference rwopsTest4
 
static const SDLTest_TestCaseReference rwopsTest5
 
static const SDLTest_TestCaseReference rwopsTest6
 
static const SDLTest_TestCaseReference rwopsTest7
 
static const SDLTest_TestCaseReference rwopsTest8
 
static const SDLTest_TestCaseReference rwopsTest9
 
static const SDLTest_TestCaseReference rwopsTest10
 
static const SDLTest_TestCaseReferencerwopsTests []
 
SDLTest_TestSuiteReference rwopsTestSuite
 

Macro Definition Documentation

◆ _CRT_SECURE_NO_WARNINGS

#define _CRT_SECURE_NO_WARNINGS

Automated SDL_RWops test.

Original code written by Edgar Simo "bobbens" Ported by Markus Kauppila (marku.nosp@m.s.ka.nosp@m.uppil.nosp@m.a@gm.nosp@m.ail.c.nosp@m.om) Updated and extended for SDL_test by aschiffler at ferzkopp dot net

Released under Public Domain.

Definition at line 13 of file testautomation_rwops.c.

Function Documentation

◆ _testGenericRWopsValidations()

void _testGenericRWopsValidations ( SDL_RWops rw,
int  write 
)

Makes sure parameters work properly. Local helper function.

See also
http://wiki.libsdl.org/moin.cgi/SDL_RWseek http://wiki.libsdl.org/moin.cgi/SDL_RWread

Definition at line 95 of file testautomation_rwops.c.

References i, RW_SEEK_CUR, RW_SEEK_END, RW_SEEK_SET, RWopsHelloWorldTestString, SDL_memcmp, SDL_PRIs64, SDL_RWread, SDL_RWseek, SDL_RWwrite, SDL_zero, SDLTest_AssertCheck(), SDLTest_AssertPass(), and SDLTest_RandomIntegerInRange().

Referenced by rwops_testConstMem(), rwops_testFileRead(), rwops_testFileWrite(), rwops_testFPRead(), rwops_testFPWrite(), and rwops_testMem().

96 {
97  char buf[sizeof(RWopsHelloWorldTestString)];
98  Sint64 i;
99  size_t s;
100  int seekPos = SDLTest_RandomIntegerInRange(4, 8);
101 
102  /* Clear buffer */
103  SDL_zero(buf);
104 
105  /* Set to start. */
106  i = SDL_RWseek(rw, 0, RW_SEEK_SET );
107  SDLTest_AssertPass("Call to SDL_RWseek succeeded");
108  SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %"SDL_PRIs64, i);
109 
110  /* Test write. */
112  SDLTest_AssertPass("Call to SDL_RWwrite succeeded");
113  if (write) {
114  SDLTest_AssertCheck(s == (size_t)1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", (int) s);
115  }
116  else {
117  SDLTest_AssertCheck(s == (size_t)0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", (int) s);
118  }
119 
120  /* Test seek to random position */
121  i = SDL_RWseek( rw, seekPos, RW_SEEK_SET );
122  SDLTest_AssertPass("Call to SDL_RWseek succeeded");
123  SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (RW_SEEK_SET), expected %i, got %"SDL_PRIs64, seekPos, seekPos, i);
124 
125  /* Test seek back to start */
126  i = SDL_RWseek(rw, 0, RW_SEEK_SET );
127  SDLTest_AssertPass("Call to SDL_RWseek succeeded");
128  SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (RW_SEEK_SET), expected 0, got %"SDL_PRIs64, i);
129 
130  /* Test read */
131  s = SDL_RWread( rw, buf, 1, sizeof(RWopsHelloWorldTestString)-1 );
132  SDLTest_AssertPass("Call to SDL_RWread succeeded");
134  s == (size_t)(sizeof(RWopsHelloWorldTestString)-1),
135  "Verify result from SDL_RWread, expected %i, got %i",
136  (int) (sizeof(RWopsHelloWorldTestString)-1),
137  (int) s);
140  "Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
141 
142  /* More seek tests. */
143  i = SDL_RWseek( rw, -4, RW_SEEK_CUR );
144  SDLTest_AssertPass("Call to SDL_RWseek(...,-4,RW_SEEK_CUR) succeeded");
146  i == (Sint64)(sizeof(RWopsHelloWorldTestString)-5),
147  "Verify seek to -4 with SDL_RWseek (RW_SEEK_CUR), expected %i, got %i",
148  (int) (sizeof(RWopsHelloWorldTestString)-5),
149  (int) i);
150 
151  i = SDL_RWseek( rw, -1, RW_SEEK_END );
152  SDLTest_AssertPass("Call to SDL_RWseek(...,-1,RW_SEEK_END) succeeded");
154  i == (Sint64)(sizeof(RWopsHelloWorldTestString)-2),
155  "Verify seek to -1 with SDL_RWseek (RW_SEEK_END), expected %i, got %i",
156  (int) (sizeof(RWopsHelloWorldTestString)-2),
157  (int) i);
158 
159  /* Invalid whence seek */
160  i = SDL_RWseek( rw, 0, 999 );
161  SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded");
163  i == (Sint64)(-1),
164  "Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %i",
165  (int) i);
166 }
GLdouble s
Definition: SDL_opengl.h:2063
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max)
#define SDL_RWwrite(ctx, ptr, size, n)
Definition: SDL_rwops.h:188
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.
#define SDL_RWread(ctx, ptr, size, n)
Definition: SDL_rwops.h:187
#define RW_SEEK_END
Definition: SDL_rwops.h:176
#define SDL_RWseek(ctx, offset, whence)
Definition: SDL_rwops.h:185
#define SDL_PRIs64
Definition: SDL_stdinc.h:205
static const char RWopsHelloWorldTestString[]
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...
#define SDL_memcmp
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
GLenum GLuint GLenum GLsizei const GLchar * buf
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)
Definition: SDL_x11sym.h:50
#define RW_SEEK_SET
Definition: SDL_rwops.h:174
#define RW_SEEK_CUR
Definition: SDL_rwops.h:175
int64_t Sint64
Definition: SDL_stdinc.h:188

◆ rwops_testAllocFree()

int rwops_testAllocFree ( void  )

Tests alloc and free RW context.

See also
http://wiki.libsdl.org/moin.cgi/SDL_AllocRW
http://wiki.libsdl.org/moin.cgi/SDL_FreeRW

Definition at line 491 of file testautomation_rwops.c.

References NULL, SDL_AllocRW, SDL_FreeRW, SDL_RWOPS_UNKNOWN, SDLTest_AssertCheck(), SDLTest_AssertPass(), TEST_ABORTED, TEST_COMPLETED, and SDL_RWops::type.

492 {
493  /* Allocate context */
494  SDL_RWops *rw = SDL_AllocRW();
495  SDLTest_AssertPass("Call to SDL_AllocRW() succeeded");
496  SDLTest_AssertCheck(rw != NULL, "Validate result from SDL_AllocRW() is not NULL");
497  if (rw==NULL) return TEST_ABORTED;
498 
499  /* Check type */
501  rw->type == SDL_RWOPS_UNKNOWN,
502  "Verify RWops type is SDL_RWOPS_UNKNOWN; expected: %d, got: %d", SDL_RWOPS_UNKNOWN, rw->type);
503 
504  /* Free context again */
505  SDL_FreeRW(rw);
506  SDLTest_AssertPass("Call to SDL_FreeRW() succeeded");
507 
508  return TEST_COMPLETED;
509 }
#define TEST_ABORTED
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.
#define SDL_RWOPS_UNKNOWN
Definition: SDL_rwops.h:42
#define SDL_AllocRW
Uint32 type
Definition: SDL_rwops.h:93
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...
#define TEST_COMPLETED
#define NULL
Definition: begin_code.h:164
#define SDL_FreeRW

◆ rwops_testCompareRWFromMemWithRWFromFile()

int rwops_testCompareRWFromMemWithRWFromFile ( void  )

Compare memory and file reads.

See also
http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem
http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile

Definition at line 518 of file testautomation_rwops.c.

References RWopsAlphabetFilename, RWopsAlphabetString, SDL_RWclose, SDL_RWFromFile, SDL_RWFromMem, SDL_RWread, SDL_RWseek, SDL_strncmp, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

519 {
520  int slen = 26;
521  char buffer_file[27];
522  char buffer_mem[27];
523  size_t rv_file;
524  size_t rv_mem;
525  Uint64 sv_file;
526  Uint64 sv_mem;
527  SDL_RWops* rwops_file;
528  SDL_RWops* rwops_mem;
529  int size;
530  int result;
531 
532 
533  for (size=5; size<10; size++)
534  {
535  /* Terminate buffer */
536  buffer_file[slen] = 0;
537  buffer_mem[slen] = 0;
538 
539  /* Read/seek from memory */
540  rwops_mem = SDL_RWFromMem((void *)RWopsAlphabetString, slen);
541  SDLTest_AssertPass("Call to SDL_RWFromMem()");
542  rv_mem = SDL_RWread(rwops_mem, buffer_mem, size, 6);
543  SDLTest_AssertPass("Call to SDL_RWread(mem, size=%d)", size);
544  sv_mem = SDL_RWseek(rwops_mem, 0, SEEK_END);
545  SDLTest_AssertPass("Call to SDL_RWseek(mem,SEEK_END)");
546  result = SDL_RWclose(rwops_mem);
547  SDLTest_AssertPass("Call to SDL_RWclose(mem)");
548  SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
549 
550  /* Read/see from file */
551  rwops_file = SDL_RWFromFile(RWopsAlphabetFilename, "r");
552  SDLTest_AssertPass("Call to SDL_RWFromFile()");
553  rv_file = SDL_RWread(rwops_file, buffer_file, size, 6);
554  SDLTest_AssertPass("Call to SDL_RWread(file, size=%d)", size);
555  sv_file = SDL_RWseek(rwops_file, 0, SEEK_END);
556  SDLTest_AssertPass("Call to SDL_RWseek(file,SEEK_END)");
557  result = SDL_RWclose(rwops_file);
558  SDLTest_AssertPass("Call to SDL_RWclose(file)");
559  SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
560 
561  /* Compare */
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);
572  }
573 
574  return TEST_COMPLETED;
575 }
GLuint64EXT * result
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.
#define SDL_RWread(ctx, ptr, size, n)
Definition: SDL_rwops.h:187
#define SDL_strncmp
uint64_t Uint64
Definition: SDL_stdinc.h:194
#define SDL_RWseek(ctx, offset, whence)
Definition: SDL_rwops.h:185
#define SDL_RWFromFile
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...
#define SDL_RWFromMem
#define TEST_COMPLETED
static const char RWopsAlphabetString[]
GLsizeiptr size
#define SDL_RWclose(ctx)
Definition: SDL_rwops.h:189

◆ rwops_testConstMem()

int rwops_testConstMem ( void  )

Tests opening from memory.

See also
http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem http://wiki.libsdl.org/moin.cgi/SDL_RWClose

Definition at line 262 of file testautomation_rwops.c.

References _testGenericRWopsValidations(), NULL, RWopsHelloWorldCompString, SDL_RWclose, SDL_RWFromConstMem, SDL_RWOPS_MEMORY_RO, SDLTest_AssertCheck(), SDLTest_AssertPass(), TEST_ABORTED, TEST_COMPLETED, and SDL_RWops::type.

263 {
264  SDL_RWops *rw;
265  int result;
266 
267  /* Open handle */
269  SDLTest_AssertPass("Call to SDL_RWFromConstMem() succeeded");
270  SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromConstMem does not return NULL");
271 
272  /* Bail out if NULL */
273  if (rw == NULL) return TEST_ABORTED;
274 
275  /* Check type */
276  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);
277 
278  /* Run generic tests */
280 
281  /* Close handle */
282  result = SDL_RWclose(rw);
283  SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
284  SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
285 
286  return TEST_COMPLETED;
287 }
#define TEST_ABORTED
GLuint64EXT * result
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.
Uint32 type
Definition: SDL_rwops.h:93
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...
#define TEST_COMPLETED
#define NULL
Definition: begin_code.h:164
#define SDL_RWclose(ctx)
Definition: SDL_rwops.h:189
#define SDL_RWOPS_MEMORY_RO
Definition: SDL_rwops.h:47
#define SDL_RWFromConstMem
void _testGenericRWopsValidations(SDL_RWops *rw, int write)
Makes sure parameters work properly. Local helper function.
static const char RWopsHelloWorldCompString[]

◆ rwops_testFileRead()

int rwops_testFileRead ( void  )

Tests reading from file.

See also
http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile http://wiki.libsdl.org/moin.cgi/SDL_RWClose

Definition at line 298 of file testautomation_rwops.c.

References _testGenericRWopsValidations(), NULL, RWopsReadTestFilename, SDL_RWclose, SDL_RWFromFile, SDL_RWOPS_JNIFILE, SDL_RWOPS_STDFILE, SDL_RWOPS_WINFILE, SDLTest_AssertCheck(), SDLTest_AssertPass(), TEST_ABORTED, TEST_COMPLETED, and SDL_RWops::type.

299 {
300  SDL_RWops *rw;
301  int result;
302 
303  /* Read test. */
305  SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"r\") succeeded");
306  SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in read mode does not return NULL");
307 
308  /* Bail out if NULL */
309  if (rw == NULL) return TEST_ABORTED;
310 
311  /* Check type */
312 #if defined(__ANDROID__)
314  rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE,
315  "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type);
316 #elif defined(__WIN32__)
318  rw->type == SDL_RWOPS_WINFILE,
319  "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type);
320 #else
322  rw->type == SDL_RWOPS_STDFILE,
323  "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
324 #endif
325 
326  /* Run generic tests */
328 
329  /* Close handle */
330  result = SDL_RWclose(rw);
331  SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
332  SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
333 
334  return TEST_COMPLETED;
335 }
#define TEST_ABORTED
GLuint64EXT * result
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.
#define SDL_RWOPS_WINFILE
Definition: SDL_rwops.h:43
Uint32 type
Definition: SDL_rwops.h:93
#define SDL_RWFromFile
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...
#define TEST_COMPLETED
const char * RWopsReadTestFilename
#define NULL
Definition: begin_code.h:164
#define SDL_RWclose(ctx)
Definition: SDL_rwops.h:189
#define SDL_RWOPS_STDFILE
Definition: SDL_rwops.h:44
void _testGenericRWopsValidations(SDL_RWops *rw, int write)
Makes sure parameters work properly. Local helper function.
#define SDL_RWOPS_JNIFILE
Definition: SDL_rwops.h:45

◆ rwops_testFileWrite()

int rwops_testFileWrite ( void  )

Tests writing from file.

See also
http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile http://wiki.libsdl.org/moin.cgi/SDL_RWClose

Definition at line 345 of file testautomation_rwops.c.

References _testGenericRWopsValidations(), NULL, RWopsWriteTestFilename, SDL_RWclose, SDL_RWFromFile, SDL_RWOPS_JNIFILE, SDL_RWOPS_STDFILE, SDL_RWOPS_WINFILE, SDLTest_AssertCheck(), SDLTest_AssertPass(), TEST_ABORTED, TEST_COMPLETED, and SDL_RWops::type.

346 {
347  SDL_RWops *rw;
348  int result;
349 
350  /* Write test. */
352  SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\") succeeded");
353  SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL");
354 
355  /* Bail out if NULL */
356  if (rw == NULL) return TEST_ABORTED;
357 
358  /* Check type */
359 #if defined(__ANDROID__)
361  rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE,
362  "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type);
363 #elif defined(__WIN32__)
365  rw->type == SDL_RWOPS_WINFILE,
366  "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type);
367 #else
369  rw->type == SDL_RWOPS_STDFILE,
370  "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
371 #endif
372 
373  /* Run generic tests */
375 
376  /* Close handle */
377  result = SDL_RWclose(rw);
378  SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
379  SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
380 
381  return TEST_COMPLETED;
382 }
#define TEST_ABORTED
GLuint64EXT * result
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.
#define SDL_RWOPS_WINFILE
Definition: SDL_rwops.h:43
Uint32 type
Definition: SDL_rwops.h:93
#define SDL_RWFromFile
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...
const char * RWopsWriteTestFilename
#define TEST_COMPLETED
#define NULL
Definition: begin_code.h:164
#define SDL_RWclose(ctx)
Definition: SDL_rwops.h:189
#define SDL_RWOPS_STDFILE
Definition: SDL_rwops.h:44
void _testGenericRWopsValidations(SDL_RWops *rw, int write)
Makes sure parameters work properly. Local helper function.
#define SDL_RWOPS_JNIFILE
Definition: SDL_rwops.h:45

◆ rwops_testFileWriteReadEndian()

int rwops_testFileWriteReadEndian ( void  )

Tests writing and reading from file using endian aware functions.

See also
http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile http://wiki.libsdl.org/moin.cgi/SDL_RWClose http://wiki.libsdl.org/moin.cgi/SDL_ReadBE16 http://wiki.libsdl.org/moin.cgi/SDL_WriteBE16

Definition at line 587 of file testautomation_rwops.c.

References NULL, RW_SEEK_SET, RWopsWriteTestFilename, SDL_PRIu64, SDL_ReadBE16, SDL_ReadBE32, SDL_ReadBE64, SDL_ReadLE16, SDL_ReadLE32, SDL_ReadLE64, SDL_RWclose, SDL_RWFromFile, SDL_RWseek, SDL_WriteBE16, SDL_WriteBE32, SDL_WriteBE64, SDL_WriteLE16, SDL_WriteLE32, SDL_WriteLE64, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_Log(), SDLTest_RandomUint16(), SDLTest_RandomUint32(), SDLTest_RandomUint64(), TEST_ABORTED, and TEST_COMPLETED.

588 {
589  SDL_RWops *rw;
590  Sint64 result;
591  int mode;
592  size_t objectsWritten;
593  Uint16 BE16value;
594  Uint32 BE32value;
595  Uint64 BE64value;
596  Uint16 LE16value;
597  Uint32 LE32value;
598  Uint64 LE64value;
599  Uint16 BE16test;
600  Uint32 BE32test;
601  Uint64 BE64test;
602  Uint16 LE16test;
603  Uint32 LE32test;
604  Uint64 LE64test;
605  int cresult;
606 
607  for (mode = 0; mode < 3; mode++) {
608 
609  /* Create test data */
610  switch (mode) {
611  case 0:
612  SDLTest_Log("All 0 values");
613  BE16value = 0;
614  BE32value = 0;
615  BE64value = 0;
616  LE16value = 0;
617  LE32value = 0;
618  LE64value = 0;
619  break;
620  case 1:
621  SDLTest_Log("All 1 values");
622  BE16value = 1;
623  BE32value = 1;
624  BE64value = 1;
625  LE16value = 1;
626  LE32value = 1;
627  LE64value = 1;
628  break;
629  case 2:
630  SDLTest_Log("Random values");
631  BE16value = SDLTest_RandomUint16();
632  BE32value = SDLTest_RandomUint32();
633  BE64value = SDLTest_RandomUint64();
634  LE16value = SDLTest_RandomUint16();
635  LE32value = SDLTest_RandomUint32();
636  LE64value = SDLTest_RandomUint64();
637  break;
638  }
639 
640  /* Write test. */
642  SDLTest_AssertPass("Call to SDL_RWFromFile(..,\"w+\")");
643  SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFile in write mode does not return NULL");
644 
645  /* Bail out if NULL */
646  if (rw == NULL) return TEST_ABORTED;
647 
648  /* Write test data */
649  objectsWritten = SDL_WriteBE16(rw, BE16value);
650  SDLTest_AssertPass("Call to SDL_WriteBE16()");
651  SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
652  objectsWritten = SDL_WriteBE32(rw, BE32value);
653  SDLTest_AssertPass("Call to SDL_WriteBE32()");
654  SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
655  objectsWritten = SDL_WriteBE64(rw, BE64value);
656  SDLTest_AssertPass("Call to SDL_WriteBE64()");
657  SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
658  objectsWritten = SDL_WriteLE16(rw, LE16value);
659  SDLTest_AssertPass("Call to SDL_WriteLE16()");
660  SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
661  objectsWritten = SDL_WriteLE32(rw, LE32value);
662  SDLTest_AssertPass("Call to SDL_WriteLE32()");
663  SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
664  objectsWritten = SDL_WriteLE64(rw, LE64value);
665  SDLTest_AssertPass("Call to SDL_WriteLE64()");
666  SDLTest_AssertCheck(objectsWritten == 1, "Validate number of objects written, expected: 1, got: %i", (int) objectsWritten);
667 
668  /* Test seek to start */
669  result = SDL_RWseek( rw, 0, RW_SEEK_SET );
670  SDLTest_AssertPass("Call to SDL_RWseek succeeded");
671  SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %i", (int) result);
672 
673  /* Read test data */
674  BE16test = SDL_ReadBE16(rw);
675  SDLTest_AssertPass("Call to SDL_ReadBE16()");
676  SDLTest_AssertCheck(BE16test == BE16value, "Validate return value from SDL_ReadBE16, expected: %hu, got: %hu", BE16value, BE16test);
677  BE32test = SDL_ReadBE32(rw);
678  SDLTest_AssertPass("Call to SDL_ReadBE32()");
679  SDLTest_AssertCheck(BE32test == BE32value, "Validate return value from SDL_ReadBE32, expected: %u, got: %u", BE32value, BE32test);
680  BE64test = SDL_ReadBE64(rw);
681  SDLTest_AssertPass("Call to SDL_ReadBE64()");
682  SDLTest_AssertCheck(BE64test == BE64value, "Validate return value from SDL_ReadBE64, expected: %"SDL_PRIu64", got: %"SDL_PRIu64, BE64value, BE64test);
683  LE16test = SDL_ReadLE16(rw);
684  SDLTest_AssertPass("Call to SDL_ReadLE16()");
685  SDLTest_AssertCheck(LE16test == LE16value, "Validate return value from SDL_ReadLE16, expected: %hu, got: %hu", LE16value, LE16test);
686  LE32test = SDL_ReadLE32(rw);
687  SDLTest_AssertPass("Call to SDL_ReadLE32()");
688  SDLTest_AssertCheck(LE32test == LE32value, "Validate return value from SDL_ReadLE32, expected: %u, got: %u", LE32value, LE32test);
689  LE64test = SDL_ReadLE64(rw);
690  SDLTest_AssertPass("Call to SDL_ReadLE64()");
691  SDLTest_AssertCheck(LE64test == LE64value, "Validate return value from SDL_ReadLE64, expected: %"SDL_PRIu64", got: %"SDL_PRIu64, LE64value, LE64test);
692 
693  /* Close handle */
694  cresult = SDL_RWclose(rw);
695  SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
696  SDLTest_AssertCheck(cresult == 0, "Verify result value is 0; got: %d", cresult);
697  }
698 
699  return TEST_COMPLETED;
700 }
#define TEST_ABORTED
GLuint64EXT * result
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.
#define SDL_WriteBE16
#define SDL_WriteLE16
#define SDL_ReadLE32
Uint32 SDLTest_RandomUint32(void)
uint32_t Uint32
Definition: SDL_stdinc.h:181
uint64_t Uint64
Definition: SDL_stdinc.h:194
#define SDL_ReadBE32
#define SDL_RWseek(ctx, offset, whence)
Definition: SDL_rwops.h:185
#define SDL_ReadLE16
#define SDL_WriteBE64
#define SDL_RWFromFile
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)
#define SDL_ReadLE64
GLenum mode
const char * RWopsWriteTestFilename
#define TEST_COMPLETED
#define NULL
Definition: begin_code.h:164
#define SDL_ReadBE16
#define SDL_RWclose(ctx)
Definition: SDL_rwops.h:189
Uint16 SDLTest_RandomUint16(void)
#define SDL_PRIu64
Definition: SDL_stdinc.h:216
#define SDL_WriteLE32
#define RW_SEEK_SET
Definition: SDL_rwops.h:174
uint16_t Uint16
Definition: SDL_stdinc.h:169
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.
Definition: SDL_test_log.c:85
int64_t Sint64
Definition: SDL_stdinc.h:188
#define SDL_ReadBE64
#define SDL_WriteLE64
#define SDL_WriteBE32

◆ rwops_testFPRead()

int rwops_testFPRead ( void  )

Tests reading from file handle.

See also
http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP http://wiki.libsdl.org/moin.cgi/SDL_RWClose

Definition at line 394 of file testautomation_rwops.c.

References _testGenericRWopsValidations(), NULL, RWopsReadTestFilename, SDL_RWclose, SDL_RWFromFP, SDL_RWOPS_STDFILE, SDL_TRUE, SDLTest_AssertCheck(), SDLTest_AssertPass(), TEST_ABORTED, TEST_COMPLETED, and SDL_RWops::type.

395 {
396  FILE *fp;
397  SDL_RWops *rw;
398  int result;
399 
400  /* Run read tests. */
401  fp = fopen(RWopsReadTestFilename, "r");
402  SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in read mode is not NULL", RWopsReadTestFilename);
403 
404  /* Bail out if NULL */
405  if (fp == NULL) return TEST_ABORTED;
406 
407  /* Open */
408  rw = SDL_RWFromFP( fp, SDL_TRUE );
409  SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded");
410  SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in read mode does not return NULL");
411 
412  /* Bail out if NULL */
413  if (rw == NULL) {
414  fclose(fp);
415  return TEST_ABORTED;
416  }
417 
418  /* Check type */
420  rw->type == SDL_RWOPS_STDFILE,
421  "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
422 
423  /* Run generic tests */
425 
426  /* Close handle - does fclose() */
427  result = SDL_RWclose(rw);
428  SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
429  SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
430 
431  return TEST_COMPLETED;
432 }
#define TEST_ABORTED
GLuint64EXT * result
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.
Uint32 type
Definition: SDL_rwops.h:93
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...
#define TEST_COMPLETED
const char * RWopsReadTestFilename
#define NULL
Definition: begin_code.h:164
#define SDL_RWclose(ctx)
Definition: SDL_rwops.h:189
#define SDL_RWOPS_STDFILE
Definition: SDL_rwops.h:44
#define SDL_RWFromFP
void _testGenericRWopsValidations(SDL_RWops *rw, int write)
Makes sure parameters work properly. Local helper function.

◆ rwops_testFPWrite()

int rwops_testFPWrite ( void  )

Tests writing to file handle.

See also
http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP http://wiki.libsdl.org/moin.cgi/SDL_RWClose

Definition at line 444 of file testautomation_rwops.c.

References _testGenericRWopsValidations(), NULL, RWopsWriteTestFilename, SDL_RWclose, SDL_RWFromFP, SDL_RWOPS_STDFILE, SDL_TRUE, SDLTest_AssertCheck(), SDLTest_AssertPass(), TEST_ABORTED, TEST_COMPLETED, and SDL_RWops::type.

445 {
446  FILE *fp;
447  SDL_RWops *rw;
448  int result;
449 
450  /* Run write tests. */
451  fp = fopen(RWopsWriteTestFilename, "w+");
452  SDLTest_AssertCheck(fp != NULL, "Verify handle from opening file '%s' in write mode is not NULL", RWopsWriteTestFilename);
453 
454  /* Bail out if NULL */
455  if (fp == NULL) return TEST_ABORTED;
456 
457  /* Open */
458  rw = SDL_RWFromFP( fp, SDL_TRUE );
459  SDLTest_AssertPass("Call to SDL_RWFromFP() succeeded");
460  SDLTest_AssertCheck(rw != NULL, "Verify opening file with SDL_RWFromFP in write mode does not return NULL");
461 
462  /* Bail out if NULL */
463  if (rw == NULL) {
464  fclose(fp);
465  return TEST_ABORTED;
466  }
467 
468  /* Check type */
470  rw->type == SDL_RWOPS_STDFILE,
471  "Verify RWops type is SDL_RWOPS_STDFILE; expected: %d, got: %d", SDL_RWOPS_STDFILE, rw->type);
472 
473  /* Run generic tests */
475 
476  /* Close handle - does fclose() */
477  result = SDL_RWclose(rw);
478  SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
479  SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
480 
481  return TEST_COMPLETED;
482 }
#define TEST_ABORTED
GLuint64EXT * result
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.
Uint32 type
Definition: SDL_rwops.h:93
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...
const char * RWopsWriteTestFilename
#define TEST_COMPLETED
#define NULL
Definition: begin_code.h:164
#define SDL_RWclose(ctx)
Definition: SDL_rwops.h:189
#define SDL_RWOPS_STDFILE
Definition: SDL_rwops.h:44
#define SDL_RWFromFP
void _testGenericRWopsValidations(SDL_RWops *rw, int write)
Makes sure parameters work properly. Local helper function.

◆ rwops_testMem()

int rwops_testMem ( void  )

Tests opening from memory.

See also
http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem
http://wiki.libsdl.org/moin.cgi/SDL_RWClose

Definition at line 222 of file testautomation_rwops.c.

References _testGenericRWopsValidations(), NULL, RWopsHelloWorldTestString, SDL_RWclose, SDL_RWFromMem, SDL_RWOPS_MEMORY, SDL_zero, SDLTest_AssertCheck(), SDLTest_AssertPass(), TEST_ABORTED, and TEST_COMPLETED.

223 {
224  char mem[sizeof(RWopsHelloWorldTestString)];
225  SDL_RWops *rw;
226  int result;
227 
228  /* Clear buffer */
229  SDL_zero(mem);
230 
231  /* Open */
232  rw = SDL_RWFromMem(mem, sizeof(RWopsHelloWorldTestString)-1);
233  SDLTest_AssertPass("Call to SDL_RWFromMem() succeeded");
234  SDLTest_AssertCheck(rw != NULL, "Verify opening memory with SDL_RWFromMem does not return NULL");
235 
236  /* Bail out if NULL */
237  if (rw == NULL) return TEST_ABORTED;
238 
239  /* Check type */
240  SDLTest_AssertCheck(rw->type == SDL_RWOPS_MEMORY, "Verify RWops type is SDL_RWOPS_MEMORY; expected: %d, got: %d", SDL_RWOPS_MEMORY, rw->type);
241 
242  /* Run generic tests */
244 
245  /* Close */
246  result = SDL_RWclose(rw);
247  SDLTest_AssertPass("Call to SDL_RWclose() succeeded");
248  SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
249 
250  return TEST_COMPLETED;
251 }
#define TEST_ABORTED
GLuint64EXT * result
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 char RWopsHelloWorldTestString[]
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...
#define SDL_RWFromMem
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
#define TEST_COMPLETED
#define NULL
Definition: begin_code.h:164
#define SDL_RWclose(ctx)
Definition: SDL_rwops.h:189
#define SDL_RWOPS_MEMORY
Definition: SDL_rwops.h:46
void _testGenericRWopsValidations(SDL_RWops *rw, int write)
Makes sure parameters work properly. Local helper function.

◆ rwops_testParamNegative()

int rwops_testParamNegative ( void  )

Definition at line 175 of file testautomation_rwops.c.

References NULL, RWopsAlphabetString, SDL_RWFromConstMem, SDL_RWFromFile, SDL_RWFromMem, SDLTest_AssertCheck(), SDLTest_AssertPass(), and TEST_COMPLETED.

176 {
177  SDL_RWops *rwops;
178 
179  /* These should all fail. */
180  rwops = SDL_RWFromFile(NULL, NULL);
181  SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, NULL) succeeded");
182  SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, NULL) returns NULL");
183 
184  rwops = SDL_RWFromFile(NULL, "ab+");
185  SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"ab+\") succeeded");
186  SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"ab+\") returns NULL");
187 
188  rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj");
189  SDLTest_AssertPass("Call to SDL_RWFromFile(NULL, \"sldfkjsldkfj\") succeeded");
190  SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(NULL, \"sldfkjsldkfj\") returns NULL");
191 
192  rwops = SDL_RWFromFile("something", "");
193  SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", \"\") succeeded");
194  SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", \"\") returns NULL");
195 
196  rwops = SDL_RWFromFile("something", NULL);
197  SDLTest_AssertPass("Call to SDL_RWFromFile(\"something\", NULL) succeeded");
198  SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromFile(\"something\", NULL) returns NULL");
199 
200  rwops = SDL_RWFromMem((void *)NULL, 10);
201  SDLTest_AssertPass("Call to SDL_RWFromMem(NULL, 10) succeeded");
202  SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromMem(NULL, 10) returns NULL");
203 
204  rwops = SDL_RWFromMem((void *)RWopsAlphabetString, 0);
205  SDLTest_AssertPass("Call to SDL_RWFromMem(data, 0) succeeded");
206  SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromMem(data, 0) returns NULL");
207 
208  rwops = SDL_RWFromConstMem((const void *)RWopsAlphabetString, 0);
209  SDLTest_AssertPass("Call to SDL_RWFromConstMem(data, 0) succeeded");
210  SDLTest_AssertCheck(rwops == NULL, "Verify SDL_RWFromConstMem(data, 0) returns NULL");
211 
212  return TEST_COMPLETED;
213 }
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.
#define SDL_RWFromFile
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...
#define SDL_RWFromMem
#define TEST_COMPLETED
static const char RWopsAlphabetString[]
#define NULL
Definition: begin_code.h:164
#define SDL_RWFromConstMem

◆ RWopsSetUp()

void RWopsSetUp ( void arg)

Definition at line 33 of file testautomation_rwops.c.

References NULL, RWopsAlphabetFilename, RWopsAlphabetString, RWopsHelloWorldTestString, RWopsReadTestFilename, RWopsWriteTestFilename, SDL_strlen, SDLTest_AssertCheck(), and SDLTest_AssertPass().

34 {
35  size_t fileLen;
36  FILE *handle;
37  size_t writtenLen;
38  int result;
39 
40  /* Clean up from previous runs (if any); ignore errors */
41  remove(RWopsReadTestFilename);
42  remove(RWopsWriteTestFilename);
43  remove(RWopsAlphabetFilename);
44 
45  /* Create a test file */
46  handle = fopen(RWopsReadTestFilename, "w");
47  SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename);
48  if (handle == NULL) return;
49 
50  /* Write some known text into it */
52  writtenLen = fwrite(RWopsHelloWorldTestString, 1, fileLen, handle);
53  SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", (int) fileLen, (int) writtenLen);
54  result = fclose(handle);
55  SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
56 
57  /* Create a second test file */
58  handle = fopen(RWopsAlphabetFilename, "w");
59  SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsAlphabetFilename);
60  if (handle == NULL) return;
61 
62  /* Write alphabet text into it */
64  writtenLen = fwrite(RWopsAlphabetString, 1, fileLen, handle);
65  SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", (int) fileLen, (int) writtenLen);
66  result = fclose(handle);
67  SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result);
68 
69  SDLTest_AssertPass("Creation of test file completed");
70 }
GLuint64EXT * result
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.
EGLImageKHR EGLint EGLint * handle
Definition: eglext.h:937
static const char RWopsHelloWorldTestString[]
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...
const char * RWopsWriteTestFilename
static const char RWopsAlphabetString[]
const char * RWopsReadTestFilename
#define NULL
Definition: begin_code.h:164
#define SDL_strlen

◆ RWopsTearDown()

void RWopsTearDown ( void arg)

Definition at line 73 of file testautomation_rwops.c.

References RWopsAlphabetFilename, RWopsReadTestFilename, RWopsWriteTestFilename, SDLTest_AssertCheck(), and SDLTest_AssertPass().

74 {
75  int result;
76 
77  /* Remove the created files to clean up; ignore errors for write filename */
78  result = remove(RWopsReadTestFilename);
79  SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsReadTestFilename, result);
80  remove(RWopsWriteTestFilename);
81  result = remove(RWopsAlphabetFilename);
82  SDLTest_AssertCheck(result == 0, "Verify result from remove(%s), expected 0, got %i", RWopsAlphabetFilename, result);
83 
84  SDLTest_AssertPass("Cleanup of test files completed");
85 }
GLuint64EXT * result
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.
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...
const char * RWopsWriteTestFilename
const char * RWopsReadTestFilename

Variable Documentation

◆ RWopsAlphabetFilename

const char* RWopsAlphabetFilename = "rwops_alphabet"

◆ RWopsAlphabetString

const char RWopsAlphabetString[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
static

◆ RWopsHelloWorldCompString

const char RWopsHelloWorldCompString[] = "Hello World!"
static

Definition at line 27 of file testautomation_rwops.c.

Referenced by rwops_testConstMem().

◆ RWopsHelloWorldTestString

const char RWopsHelloWorldTestString[] = "Hello World!"
static

Definition at line 26 of file testautomation_rwops.c.

Referenced by _testGenericRWopsValidations(), rwops_testMem(), and RWopsSetUp().

◆ RWopsReadTestFilename

const char* RWopsReadTestFilename = "rwops_read"

◆ rwopsTest1

const SDLTest_TestCaseReference rwopsTest1
static
Initial value:
=
{ (SDLTest_TestCaseFp)rwops_testParamNegative, "rwops_testParamNegative", "Negative test for SDL_RWFromFile parameters", TEST_ENABLED }
int rwops_testParamNegative(void)
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 706 of file testautomation_rwops.c.

◆ rwopsTest10

const SDLTest_TestCaseReference rwopsTest10
static
Initial value:
=
{ (SDLTest_TestCaseFp)rwops_testCompareRWFromMemWithRWFromFile, "rwops_testCompareRWFromMemWithRWFromFile", "Compare RWFromMem and RWFromFile RWops for read and seek", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int rwops_testCompareRWFromMemWithRWFromFile(void)
Compare memory and file reads.

Definition at line 733 of file testautomation_rwops.c.

◆ rwopsTest2

const SDLTest_TestCaseReference rwopsTest2
static
Initial value:
=
{ (SDLTest_TestCaseFp)rwops_testMem, "rwops_testMem", "Tests opening from memory", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
int rwops_testMem(void)
Tests opening from memory.
#define TEST_ENABLED

Definition at line 709 of file testautomation_rwops.c.

◆ rwopsTest3

const SDLTest_TestCaseReference rwopsTest3
static
Initial value:
=
{ (SDLTest_TestCaseFp)rwops_testConstMem, "rwops_testConstMem", "Tests opening from (const) memory", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int rwops_testConstMem(void)
Tests opening from memory.

Definition at line 712 of file testautomation_rwops.c.

◆ rwopsTest4

const SDLTest_TestCaseReference rwopsTest4
static
Initial value:
=
{ (SDLTest_TestCaseFp)rwops_testFileRead, "rwops_testFileRead", "Tests reading from a file", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int rwops_testFileRead(void)
Tests reading from file.

Definition at line 715 of file testautomation_rwops.c.

◆ rwopsTest5

const SDLTest_TestCaseReference rwopsTest5
static
Initial value:
=
{ (SDLTest_TestCaseFp)rwops_testFileWrite, "rwops_testFileWrite", "Test writing to a file", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int rwops_testFileWrite(void)
Tests writing from file.

Definition at line 718 of file testautomation_rwops.c.

◆ rwopsTest6

const SDLTest_TestCaseReference rwopsTest6
static
Initial value:
=
{ (SDLTest_TestCaseFp)rwops_testFPRead, "rwops_testFPRead", "Test reading from file pointer", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int rwops_testFPRead(void)
Tests reading from file handle.

Definition at line 721 of file testautomation_rwops.c.

◆ rwopsTest7

const SDLTest_TestCaseReference rwopsTest7
static
Initial value:
=
{ (SDLTest_TestCaseFp)rwops_testFPWrite, "rwops_testFPWrite", "Test writing to file pointer", TEST_ENABLED }
int rwops_testFPWrite(void)
Tests writing to file handle.
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED

Definition at line 724 of file testautomation_rwops.c.

◆ rwopsTest8

const SDLTest_TestCaseReference rwopsTest8
static
Initial value:
=
{ (SDLTest_TestCaseFp)rwops_testAllocFree, "rwops_testAllocFree", "Test alloc and free of RW context", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int rwops_testAllocFree(void)
Tests alloc and free RW context.

Definition at line 727 of file testautomation_rwops.c.

◆ rwopsTest9

const SDLTest_TestCaseReference rwopsTest9
static
Initial value:
=
{ (SDLTest_TestCaseFp)rwops_testFileWriteReadEndian, "rwops_testFileWriteReadEndian", "Test writing and reading via the Endian aware functions", TEST_ENABLED }
int(* SDLTest_TestCaseFp)(void *arg)
#define TEST_ENABLED
int rwops_testFileWriteReadEndian(void)
Tests writing and reading from file using endian aware functions.

Definition at line 730 of file testautomation_rwops.c.

◆ rwopsTests

const SDLTest_TestCaseReference* rwopsTests[]
static
Initial value:
= {
}
static const SDLTest_TestCaseReference rwopsTest10
static const SDLTest_TestCaseReference rwopsTest3
static const SDLTest_TestCaseReference rwopsTest2
static const SDLTest_TestCaseReference rwopsTest9
static const SDLTest_TestCaseReference rwopsTest4
static const SDLTest_TestCaseReference rwopsTest1
static const SDLTest_TestCaseReference rwopsTest6
static const SDLTest_TestCaseReference rwopsTest7
#define NULL
Definition: begin_code.h:164
static const SDLTest_TestCaseReference rwopsTest5
static const SDLTest_TestCaseReference rwopsTest8

Definition at line 737 of file testautomation_rwops.c.

◆ rwopsTestSuite

Initial value:
= {
"RWops",
}
static const SDLTest_TestCaseReference * rwopsTests[]
void RWopsSetUp(void *arg)
void RWopsTearDown(void *arg)

Definition at line 743 of file testautomation_rwops.c.

◆ RWopsWriteTestFilename

const char* RWopsWriteTestFilename = "rwops_write"