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