test/testfile.c
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1659 14717b52abc0
child 1668 4da1ee79c9af
     1.1 --- a/test/testfile.c	Sun May 21 17:27:13 2006 +0000
     1.2 +++ b/test/testfile.c	Sun May 28 13:04:16 2006 +0000
     1.3 @@ -8,172 +8,254 @@
     1.4  #include "SDL_endian.h"
     1.5  
     1.6  
     1.7 -#include <stdio.h>	
     1.8 +#include <stdio.h>
     1.9  
    1.10  /* WARNING ! those 2 files will be destroyed by this test program */
    1.11 -#define FBASENAME1	"sdldata1"		/* this file will be created during tests */
    1.12 -#define FBASENAME2	"sdldata2"		/* this file should not exists before starting test */
    1.13 +#define FBASENAME1	"sdldata1"      /* this file will be created during tests */
    1.14 +#define FBASENAME2	"sdldata2"      /* this file should not exists before starting test */
    1.15  
    1.16  
    1.17  #ifndef NULL
    1.18  #define NULL ((void *)0)
    1.19 -#endif 
    1.20 +#endif
    1.21  
    1.22 -static void cleanup( void ) {
    1.23 +static void
    1.24 +cleanup (void)
    1.25 +{
    1.26  
    1.27 -	unlink(FBASENAME1);
    1.28 -	unlink(FBASENAME2); 
    1.29 +    unlink (FBASENAME1);
    1.30 +    unlink (FBASENAME2);
    1.31  }
    1.32  
    1.33 -static void rwops_error_quit( unsigned line, SDL_RWops *rwops) {
    1.34 -	
    1.35 -	printf("testfile.c(%d): failed\n",line);
    1.36 -	if (rwops) {
    1.37 -		rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */
    1.38 -	}
    1.39 -	cleanup();
    1.40 -	exit(1); /* quit with rwops error (test failed) */
    1.41 +static void
    1.42 +rwops_error_quit (unsigned line, SDL_RWops * rwops)
    1.43 +{
    1.44 +
    1.45 +    printf ("testfile.c(%d): failed\n", line);
    1.46 +    if (rwops) {
    1.47 +        rwops->close (rwops);   /* This calls SDL_FreeRW(rwops); */
    1.48 +    }
    1.49 +    cleanup ();
    1.50 +    exit (1);                   /* quit with rwops error (test failed) */
    1.51  }
    1.52  
    1.53  #define RWOP_ERR_QUIT(x)	rwops_error_quit( __LINE__, (x) )
    1.54  
    1.55  
    1.56  
    1.57 -int main(int argc, char *argv[])
    1.58 +int
    1.59 +main (int argc, char *argv[])
    1.60  {
    1.61 -	SDL_RWops *rwops = NULL;
    1.62 -	char test_buf[30];
    1.63 -	
    1.64 -	cleanup();
    1.65 +    SDL_RWops *rwops = NULL;
    1.66 +    char test_buf[30];
    1.67 +
    1.68 +    cleanup ();
    1.69  
    1.70  /* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */
    1.71 -	
    1.72 -	rwops = SDL_RWFromFile(NULL,NULL);
    1.73 -	if (rwops) RWOP_ERR_QUIT(rwops);
    1.74 -	rwops = SDL_RWFromFile(NULL,"ab+");
    1.75 -	if (rwops) RWOP_ERR_QUIT(rwops);
    1.76 -	rwops = SDL_RWFromFile(NULL,"sldfkjsldkfj");
    1.77 -	if (rwops) RWOP_ERR_QUIT(rwops);
    1.78 -	rwops = SDL_RWFromFile("something","");
    1.79 -	if (rwops) RWOP_ERR_QUIT(rwops);
    1.80 -	rwops = SDL_RWFromFile("something",NULL);
    1.81 -	if (rwops) RWOP_ERR_QUIT(rwops);	
    1.82 -	printf("test1 OK\n");
    1.83 +
    1.84 +    rwops = SDL_RWFromFile (NULL, NULL);
    1.85 +    if (rwops)
    1.86 +        RWOP_ERR_QUIT (rwops);
    1.87 +    rwops = SDL_RWFromFile (NULL, "ab+");
    1.88 +    if (rwops)
    1.89 +        RWOP_ERR_QUIT (rwops);
    1.90 +    rwops = SDL_RWFromFile (NULL, "sldfkjsldkfj");
    1.91 +    if (rwops)
    1.92 +        RWOP_ERR_QUIT (rwops);
    1.93 +    rwops = SDL_RWFromFile ("something", "");
    1.94 +    if (rwops)
    1.95 +        RWOP_ERR_QUIT (rwops);
    1.96 +    rwops = SDL_RWFromFile ("something", NULL);
    1.97 +    if (rwops)
    1.98 +        RWOP_ERR_QUIT (rwops);
    1.99 +    printf ("test1 OK\n");
   1.100  
   1.101  /* test 2 : check that inexistant file is not successfully opened/created when required */
   1.102  /* modes : r, r+ implie that file MUST exist 
   1.103     modes : a, a+, w, w+ checks that it succeeds (file may not exists)
   1.104     
   1.105   */
   1.106 -	rwops = SDL_RWFromFile(FBASENAME2,"rb"); /* this file doesn't exist that call must fail */
   1.107 -	if (rwops) RWOP_ERR_QUIT(rwops);
   1.108 -	rwops = SDL_RWFromFile(FBASENAME2,"rb+"); /* this file doesn't exist that call must fail */
   1.109 -	if (rwops) RWOP_ERR_QUIT(rwops);
   1.110 -	rwops = SDL_RWFromFile(FBASENAME2,"wb");
   1.111 -	if (!rwops) RWOP_ERR_QUIT(rwops); 
   1.112 -	rwops->close(rwops); unlink(FBASENAME2);
   1.113 -	rwops = SDL_RWFromFile(FBASENAME2,"wb+");
   1.114 -	if (!rwops) RWOP_ERR_QUIT(rwops); 
   1.115 -	rwops->close(rwops); unlink(FBASENAME2);
   1.116 -	rwops = SDL_RWFromFile(FBASENAME2,"ab"); 
   1.117 -	if (!rwops) RWOP_ERR_QUIT(rwops); 
   1.118 -	rwops->close(rwops); unlink(FBASENAME2);
   1.119 -	rwops = SDL_RWFromFile(FBASENAME2,"ab+");
   1.120 -	if (!rwops) RWOP_ERR_QUIT(rwops); 
   1.121 -	rwops->close(rwops); unlink(FBASENAME2);
   1.122 -	printf("test2 OK\n");
   1.123 +    rwops = SDL_RWFromFile (FBASENAME2, "rb");  /* this file doesn't exist that call must fail */
   1.124 +    if (rwops)
   1.125 +        RWOP_ERR_QUIT (rwops);
   1.126 +    rwops = SDL_RWFromFile (FBASENAME2, "rb+"); /* this file doesn't exist that call must fail */
   1.127 +    if (rwops)
   1.128 +        RWOP_ERR_QUIT (rwops);
   1.129 +    rwops = SDL_RWFromFile (FBASENAME2, "wb");
   1.130 +    if (!rwops)
   1.131 +        RWOP_ERR_QUIT (rwops);
   1.132 +    rwops->close (rwops);
   1.133 +    unlink (FBASENAME2);
   1.134 +    rwops = SDL_RWFromFile (FBASENAME2, "wb+");
   1.135 +    if (!rwops)
   1.136 +        RWOP_ERR_QUIT (rwops);
   1.137 +    rwops->close (rwops);
   1.138 +    unlink (FBASENAME2);
   1.139 +    rwops = SDL_RWFromFile (FBASENAME2, "ab");
   1.140 +    if (!rwops)
   1.141 +        RWOP_ERR_QUIT (rwops);
   1.142 +    rwops->close (rwops);
   1.143 +    unlink (FBASENAME2);
   1.144 +    rwops = SDL_RWFromFile (FBASENAME2, "ab+");
   1.145 +    if (!rwops)
   1.146 +        RWOP_ERR_QUIT (rwops);
   1.147 +    rwops->close (rwops);
   1.148 +    unlink (FBASENAME2);
   1.149 +    printf ("test2 OK\n");
   1.150  
   1.151  /* test 3 : creation, writing , reading, seeking, 
   1.152  	        test : w mode, r mode, w+ mode
   1.153   */
   1.154 -	rwops = SDL_RWFromFile(FBASENAME1,"wb"); /* write only */	
   1.155 -	if (!rwops)											RWOP_ERR_QUIT(rwops);
   1.156 -	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
   1.157 -	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
   1.158 -	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops);		
   1.159 -	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   1.160 -	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); /* we are in write only mode */
   1.161 -	rwops->close(rwops);
   1.162 +    rwops = SDL_RWFromFile (FBASENAME1, "wb");  /* write only */
   1.163 +    if (!rwops)
   1.164 +        RWOP_ERR_QUIT (rwops);
   1.165 +    if (1 != rwops->write (rwops, "1234567890", 10, 1))
   1.166 +        RWOP_ERR_QUIT (rwops);
   1.167 +    if (10 != rwops->write (rwops, "1234567890", 1, 10))
   1.168 +        RWOP_ERR_QUIT (rwops);
   1.169 +    if (7 != rwops->write (rwops, "1234567", 1, 7))
   1.170 +        RWOP_ERR_QUIT (rwops);
   1.171 +    if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   1.172 +        RWOP_ERR_QUIT (rwops);
   1.173 +    if (0 != rwops->read (rwops, test_buf, 1, 1))
   1.174 +        RWOP_ERR_QUIT (rwops);  /* we are in write only mode */
   1.175 +    rwops->close (rwops);
   1.176  
   1.177 -	rwops = SDL_RWFromFile(FBASENAME1,"rb"); /* read mode, file must exists */
   1.178 -	if (!rwops)											RWOP_ERR_QUIT(rwops);
   1.179 -	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   1.180 -	if (20!=rwops->seek(rwops,-7,RW_SEEK_END))			RWOP_ERR_QUIT(rwops);					
   1.181 -	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
   1.182 -	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
   1.183 -	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
   1.184 -	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
   1.185 -	if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);		
   1.186 -	if (2!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
   1.187 -	if (SDL_memcmp(test_buf,"12345678901234567890",20))	RWOP_ERR_QUIT(rwops);
   1.188 -	if (0!=rwops->write(rwops,test_buf,1,1))			RWOP_ERR_QUIT(rwops); /* readonly mode */
   1.189 -	rwops->close(rwops);
   1.190 +    rwops = SDL_RWFromFile (FBASENAME1, "rb");  /* read mode, file must exists */
   1.191 +    if (!rwops)
   1.192 +        RWOP_ERR_QUIT (rwops);
   1.193 +    if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   1.194 +        RWOP_ERR_QUIT (rwops);
   1.195 +    if (20 != rwops->seek (rwops, -7, RW_SEEK_END))
   1.196 +        RWOP_ERR_QUIT (rwops);
   1.197 +    if (7 != rwops->read (rwops, test_buf, 1, 7))
   1.198 +        RWOP_ERR_QUIT (rwops);
   1.199 +    if (SDL_memcmp (test_buf, "1234567", 7))
   1.200 +        RWOP_ERR_QUIT (rwops);
   1.201 +    if (0 != rwops->read (rwops, test_buf, 1, 1))
   1.202 +        RWOP_ERR_QUIT (rwops);
   1.203 +    if (0 != rwops->read (rwops, test_buf, 10, 100))
   1.204 +        RWOP_ERR_QUIT (rwops);
   1.205 +    if (0 != rwops->seek (rwops, -27, RW_SEEK_CUR))
   1.206 +        RWOP_ERR_QUIT (rwops);
   1.207 +    if (2 != rwops->read (rwops, test_buf, 10, 3))
   1.208 +        RWOP_ERR_QUIT (rwops);
   1.209 +    if (SDL_memcmp (test_buf, "12345678901234567890", 20))
   1.210 +        RWOP_ERR_QUIT (rwops);
   1.211 +    if (0 != rwops->write (rwops, test_buf, 1, 1))
   1.212 +        RWOP_ERR_QUIT (rwops);  /* readonly mode */
   1.213 +    rwops->close (rwops);
   1.214  
   1.215  /* test 3: same with w+ mode */
   1.216 -	rwops = SDL_RWFromFile(FBASENAME1,"wb+"); /* write + read + truncation */		
   1.217 -	if (!rwops)											RWOP_ERR_QUIT(rwops);
   1.218 -	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
   1.219 -	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
   1.220 -	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops);		
   1.221 -	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   1.222 -	if (1!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); /* we are in read/write mode */
   1.223 -	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   1.224 -	if (20!=rwops->seek(rwops,-7,RW_SEEK_END))			RWOP_ERR_QUIT(rwops);					
   1.225 -	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
   1.226 -	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
   1.227 -	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
   1.228 -	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
   1.229 -	if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);		
   1.230 -	if (2!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
   1.231 -	if (SDL_memcmp(test_buf,"12345678901234567890",20))	RWOP_ERR_QUIT(rwops);
   1.232 -	rwops->close(rwops);
   1.233 -	printf("test3 OK\n");
   1.234 +    rwops = SDL_RWFromFile (FBASENAME1, "wb+"); /* write + read + truncation */
   1.235 +    if (!rwops)
   1.236 +        RWOP_ERR_QUIT (rwops);
   1.237 +    if (1 != rwops->write (rwops, "1234567890", 10, 1))
   1.238 +        RWOP_ERR_QUIT (rwops);
   1.239 +    if (10 != rwops->write (rwops, "1234567890", 1, 10))
   1.240 +        RWOP_ERR_QUIT (rwops);
   1.241 +    if (7 != rwops->write (rwops, "1234567", 1, 7))
   1.242 +        RWOP_ERR_QUIT (rwops);
   1.243 +    if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   1.244 +        RWOP_ERR_QUIT (rwops);
   1.245 +    if (1 != rwops->read (rwops, test_buf, 1, 1))
   1.246 +        RWOP_ERR_QUIT (rwops);  /* we are in read/write mode */
   1.247 +    if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   1.248 +        RWOP_ERR_QUIT (rwops);
   1.249 +    if (20 != rwops->seek (rwops, -7, RW_SEEK_END))
   1.250 +        RWOP_ERR_QUIT (rwops);
   1.251 +    if (7 != rwops->read (rwops, test_buf, 1, 7))
   1.252 +        RWOP_ERR_QUIT (rwops);
   1.253 +    if (SDL_memcmp (test_buf, "1234567", 7))
   1.254 +        RWOP_ERR_QUIT (rwops);
   1.255 +    if (0 != rwops->read (rwops, test_buf, 1, 1))
   1.256 +        RWOP_ERR_QUIT (rwops);
   1.257 +    if (0 != rwops->read (rwops, test_buf, 10, 100))
   1.258 +        RWOP_ERR_QUIT (rwops);
   1.259 +    if (0 != rwops->seek (rwops, -27, RW_SEEK_CUR))
   1.260 +        RWOP_ERR_QUIT (rwops);
   1.261 +    if (2 != rwops->read (rwops, test_buf, 10, 3))
   1.262 +        RWOP_ERR_QUIT (rwops);
   1.263 +    if (SDL_memcmp (test_buf, "12345678901234567890", 20))
   1.264 +        RWOP_ERR_QUIT (rwops);
   1.265 +    rwops->close (rwops);
   1.266 +    printf ("test3 OK\n");
   1.267  
   1.268  /* test 4: same in r+ mode */
   1.269 -	rwops = SDL_RWFromFile(FBASENAME1,"rb+"); /* write + read + file must exists, no truncation */		
   1.270 -	if (!rwops)											RWOP_ERR_QUIT(rwops);
   1.271 -	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
   1.272 -	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
   1.273 -	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops);		
   1.274 -	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   1.275 -	if (1!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); /* we are in read/write mode */
   1.276 -	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   1.277 -	if (20!=rwops->seek(rwops,-7,RW_SEEK_END))			RWOP_ERR_QUIT(rwops);					
   1.278 -	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
   1.279 -	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
   1.280 -	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
   1.281 -	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
   1.282 -	if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);		
   1.283 -	if (2!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
   1.284 -	if (SDL_memcmp(test_buf,"12345678901234567890",20))	RWOP_ERR_QUIT(rwops);
   1.285 -	rwops->close(rwops);
   1.286 -	printf("test4 OK\n");
   1.287 +    rwops = SDL_RWFromFile (FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */
   1.288 +    if (!rwops)
   1.289 +        RWOP_ERR_QUIT (rwops);
   1.290 +    if (1 != rwops->write (rwops, "1234567890", 10, 1))
   1.291 +        RWOP_ERR_QUIT (rwops);
   1.292 +    if (10 != rwops->write (rwops, "1234567890", 1, 10))
   1.293 +        RWOP_ERR_QUIT (rwops);
   1.294 +    if (7 != rwops->write (rwops, "1234567", 1, 7))
   1.295 +        RWOP_ERR_QUIT (rwops);
   1.296 +    if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   1.297 +        RWOP_ERR_QUIT (rwops);
   1.298 +    if (1 != rwops->read (rwops, test_buf, 1, 1))
   1.299 +        RWOP_ERR_QUIT (rwops);  /* we are in read/write mode */
   1.300 +    if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   1.301 +        RWOP_ERR_QUIT (rwops);
   1.302 +    if (20 != rwops->seek (rwops, -7, RW_SEEK_END))
   1.303 +        RWOP_ERR_QUIT (rwops);
   1.304 +    if (7 != rwops->read (rwops, test_buf, 1, 7))
   1.305 +        RWOP_ERR_QUIT (rwops);
   1.306 +    if (SDL_memcmp (test_buf, "1234567", 7))
   1.307 +        RWOP_ERR_QUIT (rwops);
   1.308 +    if (0 != rwops->read (rwops, test_buf, 1, 1))
   1.309 +        RWOP_ERR_QUIT (rwops);
   1.310 +    if (0 != rwops->read (rwops, test_buf, 10, 100))
   1.311 +        RWOP_ERR_QUIT (rwops);
   1.312 +    if (0 != rwops->seek (rwops, -27, RW_SEEK_CUR))
   1.313 +        RWOP_ERR_QUIT (rwops);
   1.314 +    if (2 != rwops->read (rwops, test_buf, 10, 3))
   1.315 +        RWOP_ERR_QUIT (rwops);
   1.316 +    if (SDL_memcmp (test_buf, "12345678901234567890", 20))
   1.317 +        RWOP_ERR_QUIT (rwops);
   1.318 +    rwops->close (rwops);
   1.319 +    printf ("test4 OK\n");
   1.320  
   1.321  /* test5 : append mode */
   1.322 -	rwops = SDL_RWFromFile(FBASENAME1,"ab+"); /* write + read + append */		
   1.323 -	if (!rwops)											RWOP_ERR_QUIT(rwops);
   1.324 -	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
   1.325 -	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
   1.326 -	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops); 	
   1.327 -	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   1.328 -	
   1.329 -	if (1!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); 
   1.330 -	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   1.331 -	
   1.332 -	if (20+27!=rwops->seek(rwops,-7,RW_SEEK_END))		RWOP_ERR_QUIT(rwops);					
   1.333 -	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
   1.334 -	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
   1.335 -	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
   1.336 -	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
   1.337 -	
   1.338 -	if (27!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);
   1.339 -	
   1.340 -	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);
   1.341 -	if (3!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
   1.342 -	if (SDL_memcmp(test_buf,"123456789012345678901234567123",30))	
   1.343 -														RWOP_ERR_QUIT(rwops);
   1.344 -	rwops->close(rwops);
   1.345 -	printf("test5 OK\n");
   1.346 -	cleanup();
   1.347 -	return 0; /* all ok */
   1.348 +    rwops = SDL_RWFromFile (FBASENAME1, "ab+"); /* write + read + append */
   1.349 +    if (!rwops)
   1.350 +        RWOP_ERR_QUIT (rwops);
   1.351 +    if (1 != rwops->write (rwops, "1234567890", 10, 1))
   1.352 +        RWOP_ERR_QUIT (rwops);
   1.353 +    if (10 != rwops->write (rwops, "1234567890", 1, 10))
   1.354 +        RWOP_ERR_QUIT (rwops);
   1.355 +    if (7 != rwops->write (rwops, "1234567", 1, 7))
   1.356 +        RWOP_ERR_QUIT (rwops);
   1.357 +    if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   1.358 +        RWOP_ERR_QUIT (rwops);
   1.359 +
   1.360 +    if (1 != rwops->read (rwops, test_buf, 1, 1))
   1.361 +        RWOP_ERR_QUIT (rwops);
   1.362 +    if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   1.363 +        RWOP_ERR_QUIT (rwops);
   1.364 +
   1.365 +    if (20 + 27 != rwops->seek (rwops, -7, RW_SEEK_END))
   1.366 +        RWOP_ERR_QUIT (rwops);
   1.367 +    if (7 != rwops->read (rwops, test_buf, 1, 7))
   1.368 +        RWOP_ERR_QUIT (rwops);
   1.369 +    if (SDL_memcmp (test_buf, "1234567", 7))
   1.370 +        RWOP_ERR_QUIT (rwops);
   1.371 +    if (0 != rwops->read (rwops, test_buf, 1, 1))
   1.372 +        RWOP_ERR_QUIT (rwops);
   1.373 +    if (0 != rwops->read (rwops, test_buf, 10, 100))
   1.374 +        RWOP_ERR_QUIT (rwops);
   1.375 +
   1.376 +    if (27 != rwops->seek (rwops, -27, RW_SEEK_CUR))
   1.377 +        RWOP_ERR_QUIT (rwops);
   1.378 +
   1.379 +    if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   1.380 +        RWOP_ERR_QUIT (rwops);
   1.381 +    if (3 != rwops->read (rwops, test_buf, 10, 3))
   1.382 +        RWOP_ERR_QUIT (rwops);
   1.383 +    if (SDL_memcmp (test_buf, "123456789012345678901234567123", 30))
   1.384 +        RWOP_ERR_QUIT (rwops);
   1.385 +    rwops->close (rwops);
   1.386 +    printf ("test5 OK\n");
   1.387 +    cleanup ();
   1.388 +    return 0;                   /* all ok */
   1.389  }