test/testfile.c
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1659 14717b52abc0
child 1668 4da1ee79c9af
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
     6 
     6 
     7 #include "SDL.h"
     7 #include "SDL.h"
     8 #include "SDL_endian.h"
     8 #include "SDL_endian.h"
     9 
     9 
    10 
    10 
    11 #include <stdio.h>	
    11 #include <stdio.h>
    12 
    12 
    13 /* WARNING ! those 2 files will be destroyed by this test program */
    13 /* WARNING ! those 2 files will be destroyed by this test program */
    14 #define FBASENAME1	"sdldata1"		/* this file will be created during tests */
    14 #define FBASENAME1	"sdldata1"      /* this file will be created during tests */
    15 #define FBASENAME2	"sdldata2"		/* this file should not exists before starting test */
    15 #define FBASENAME2	"sdldata2"      /* this file should not exists before starting test */
    16 
    16 
    17 
    17 
    18 #ifndef NULL
    18 #ifndef NULL
    19 #define NULL ((void *)0)
    19 #define NULL ((void *)0)
    20 #endif 
    20 #endif
    21 
    21 
    22 static void cleanup( void ) {
    22 static void
    23 
    23 cleanup (void)
    24 	unlink(FBASENAME1);
    24 {
    25 	unlink(FBASENAME2); 
    25 
       
    26     unlink (FBASENAME1);
       
    27     unlink (FBASENAME2);
    26 }
    28 }
    27 
    29 
    28 static void rwops_error_quit( unsigned line, SDL_RWops *rwops) {
    30 static void
    29 	
    31 rwops_error_quit (unsigned line, SDL_RWops * rwops)
    30 	printf("testfile.c(%d): failed\n",line);
    32 {
    31 	if (rwops) {
    33 
    32 		rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */
    34     printf ("testfile.c(%d): failed\n", line);
    33 	}
    35     if (rwops) {
    34 	cleanup();
    36         rwops->close (rwops);   /* This calls SDL_FreeRW(rwops); */
    35 	exit(1); /* quit with rwops error (test failed) */
    37     }
       
    38     cleanup ();
       
    39     exit (1);                   /* quit with rwops error (test failed) */
    36 }
    40 }
    37 
    41 
    38 #define RWOP_ERR_QUIT(x)	rwops_error_quit( __LINE__, (x) )
    42 #define RWOP_ERR_QUIT(x)	rwops_error_quit( __LINE__, (x) )
    39 
    43 
    40 
    44 
    41 
    45 
    42 int main(int argc, char *argv[])
    46 int
       
    47 main (int argc, char *argv[])
    43 {
    48 {
    44 	SDL_RWops *rwops = NULL;
    49     SDL_RWops *rwops = NULL;
    45 	char test_buf[30];
    50     char test_buf[30];
    46 	
    51 
    47 	cleanup();
    52     cleanup ();
    48 
    53 
    49 /* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */
    54 /* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */
    50 	
    55 
    51 	rwops = SDL_RWFromFile(NULL,NULL);
    56     rwops = SDL_RWFromFile (NULL, NULL);
    52 	if (rwops) RWOP_ERR_QUIT(rwops);
    57     if (rwops)
    53 	rwops = SDL_RWFromFile(NULL,"ab+");
    58         RWOP_ERR_QUIT (rwops);
    54 	if (rwops) RWOP_ERR_QUIT(rwops);
    59     rwops = SDL_RWFromFile (NULL, "ab+");
    55 	rwops = SDL_RWFromFile(NULL,"sldfkjsldkfj");
    60     if (rwops)
    56 	if (rwops) RWOP_ERR_QUIT(rwops);
    61         RWOP_ERR_QUIT (rwops);
    57 	rwops = SDL_RWFromFile("something","");
    62     rwops = SDL_RWFromFile (NULL, "sldfkjsldkfj");
    58 	if (rwops) RWOP_ERR_QUIT(rwops);
    63     if (rwops)
    59 	rwops = SDL_RWFromFile("something",NULL);
    64         RWOP_ERR_QUIT (rwops);
    60 	if (rwops) RWOP_ERR_QUIT(rwops);	
    65     rwops = SDL_RWFromFile ("something", "");
    61 	printf("test1 OK\n");
    66     if (rwops)
       
    67         RWOP_ERR_QUIT (rwops);
       
    68     rwops = SDL_RWFromFile ("something", NULL);
       
    69     if (rwops)
       
    70         RWOP_ERR_QUIT (rwops);
       
    71     printf ("test1 OK\n");
    62 
    72 
    63 /* test 2 : check that inexistant file is not successfully opened/created when required */
    73 /* test 2 : check that inexistant file is not successfully opened/created when required */
    64 /* modes : r, r+ implie that file MUST exist 
    74 /* modes : r, r+ implie that file MUST exist 
    65    modes : a, a+, w, w+ checks that it succeeds (file may not exists)
    75    modes : a, a+, w, w+ checks that it succeeds (file may not exists)
    66    
    76    
    67  */
    77  */
    68 	rwops = SDL_RWFromFile(FBASENAME2,"rb"); /* this file doesn't exist that call must fail */
    78     rwops = SDL_RWFromFile (FBASENAME2, "rb");  /* this file doesn't exist that call must fail */
    69 	if (rwops) RWOP_ERR_QUIT(rwops);
    79     if (rwops)
    70 	rwops = SDL_RWFromFile(FBASENAME2,"rb+"); /* this file doesn't exist that call must fail */
    80         RWOP_ERR_QUIT (rwops);
    71 	if (rwops) RWOP_ERR_QUIT(rwops);
    81     rwops = SDL_RWFromFile (FBASENAME2, "rb+"); /* this file doesn't exist that call must fail */
    72 	rwops = SDL_RWFromFile(FBASENAME2,"wb");
    82     if (rwops)
    73 	if (!rwops) RWOP_ERR_QUIT(rwops); 
    83         RWOP_ERR_QUIT (rwops);
    74 	rwops->close(rwops); unlink(FBASENAME2);
    84     rwops = SDL_RWFromFile (FBASENAME2, "wb");
    75 	rwops = SDL_RWFromFile(FBASENAME2,"wb+");
    85     if (!rwops)
    76 	if (!rwops) RWOP_ERR_QUIT(rwops); 
    86         RWOP_ERR_QUIT (rwops);
    77 	rwops->close(rwops); unlink(FBASENAME2);
    87     rwops->close (rwops);
    78 	rwops = SDL_RWFromFile(FBASENAME2,"ab"); 
    88     unlink (FBASENAME2);
    79 	if (!rwops) RWOP_ERR_QUIT(rwops); 
    89     rwops = SDL_RWFromFile (FBASENAME2, "wb+");
    80 	rwops->close(rwops); unlink(FBASENAME2);
    90     if (!rwops)
    81 	rwops = SDL_RWFromFile(FBASENAME2,"ab+");
    91         RWOP_ERR_QUIT (rwops);
    82 	if (!rwops) RWOP_ERR_QUIT(rwops); 
    92     rwops->close (rwops);
    83 	rwops->close(rwops); unlink(FBASENAME2);
    93     unlink (FBASENAME2);
    84 	printf("test2 OK\n");
    94     rwops = SDL_RWFromFile (FBASENAME2, "ab");
       
    95     if (!rwops)
       
    96         RWOP_ERR_QUIT (rwops);
       
    97     rwops->close (rwops);
       
    98     unlink (FBASENAME2);
       
    99     rwops = SDL_RWFromFile (FBASENAME2, "ab+");
       
   100     if (!rwops)
       
   101         RWOP_ERR_QUIT (rwops);
       
   102     rwops->close (rwops);
       
   103     unlink (FBASENAME2);
       
   104     printf ("test2 OK\n");
    85 
   105 
    86 /* test 3 : creation, writing , reading, seeking, 
   106 /* test 3 : creation, writing , reading, seeking, 
    87 	        test : w mode, r mode, w+ mode
   107 	        test : w mode, r mode, w+ mode
    88  */
   108  */
    89 	rwops = SDL_RWFromFile(FBASENAME1,"wb"); /* write only */	
   109     rwops = SDL_RWFromFile (FBASENAME1, "wb");  /* write only */
    90 	if (!rwops)											RWOP_ERR_QUIT(rwops);
   110     if (!rwops)
    91 	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
   111         RWOP_ERR_QUIT (rwops);
    92 	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
   112     if (1 != rwops->write (rwops, "1234567890", 10, 1))
    93 	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops);		
   113         RWOP_ERR_QUIT (rwops);
    94 	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   114     if (10 != rwops->write (rwops, "1234567890", 1, 10))
    95 	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); /* we are in write only mode */
   115         RWOP_ERR_QUIT (rwops);
    96 	rwops->close(rwops);
   116     if (7 != rwops->write (rwops, "1234567", 1, 7))
    97 
   117         RWOP_ERR_QUIT (rwops);
    98 	rwops = SDL_RWFromFile(FBASENAME1,"rb"); /* read mode, file must exists */
   118     if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
    99 	if (!rwops)											RWOP_ERR_QUIT(rwops);
   119         RWOP_ERR_QUIT (rwops);
   100 	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   120     if (0 != rwops->read (rwops, test_buf, 1, 1))
   101 	if (20!=rwops->seek(rwops,-7,RW_SEEK_END))			RWOP_ERR_QUIT(rwops);					
   121         RWOP_ERR_QUIT (rwops);  /* we are in write only mode */
   102 	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
   122     rwops->close (rwops);
   103 	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
   123 
   104 	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
   124     rwops = SDL_RWFromFile (FBASENAME1, "rb");  /* read mode, file must exists */
   105 	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
   125     if (!rwops)
   106 	if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);		
   126         RWOP_ERR_QUIT (rwops);
   107 	if (2!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
   127     if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   108 	if (SDL_memcmp(test_buf,"12345678901234567890",20))	RWOP_ERR_QUIT(rwops);
   128         RWOP_ERR_QUIT (rwops);
   109 	if (0!=rwops->write(rwops,test_buf,1,1))			RWOP_ERR_QUIT(rwops); /* readonly mode */
   129     if (20 != rwops->seek (rwops, -7, RW_SEEK_END))
   110 	rwops->close(rwops);
   130         RWOP_ERR_QUIT (rwops);
       
   131     if (7 != rwops->read (rwops, test_buf, 1, 7))
       
   132         RWOP_ERR_QUIT (rwops);
       
   133     if (SDL_memcmp (test_buf, "1234567", 7))
       
   134         RWOP_ERR_QUIT (rwops);
       
   135     if (0 != rwops->read (rwops, test_buf, 1, 1))
       
   136         RWOP_ERR_QUIT (rwops);
       
   137     if (0 != rwops->read (rwops, test_buf, 10, 100))
       
   138         RWOP_ERR_QUIT (rwops);
       
   139     if (0 != rwops->seek (rwops, -27, RW_SEEK_CUR))
       
   140         RWOP_ERR_QUIT (rwops);
       
   141     if (2 != rwops->read (rwops, test_buf, 10, 3))
       
   142         RWOP_ERR_QUIT (rwops);
       
   143     if (SDL_memcmp (test_buf, "12345678901234567890", 20))
       
   144         RWOP_ERR_QUIT (rwops);
       
   145     if (0 != rwops->write (rwops, test_buf, 1, 1))
       
   146         RWOP_ERR_QUIT (rwops);  /* readonly mode */
       
   147     rwops->close (rwops);
   111 
   148 
   112 /* test 3: same with w+ mode */
   149 /* test 3: same with w+ mode */
   113 	rwops = SDL_RWFromFile(FBASENAME1,"wb+"); /* write + read + truncation */		
   150     rwops = SDL_RWFromFile (FBASENAME1, "wb+"); /* write + read + truncation */
   114 	if (!rwops)											RWOP_ERR_QUIT(rwops);
   151     if (!rwops)
   115 	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
   152         RWOP_ERR_QUIT (rwops);
   116 	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
   153     if (1 != rwops->write (rwops, "1234567890", 10, 1))
   117 	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops);		
   154         RWOP_ERR_QUIT (rwops);
   118 	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   155     if (10 != rwops->write (rwops, "1234567890", 1, 10))
   119 	if (1!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); /* we are in read/write mode */
   156         RWOP_ERR_QUIT (rwops);
   120 	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   157     if (7 != rwops->write (rwops, "1234567", 1, 7))
   121 	if (20!=rwops->seek(rwops,-7,RW_SEEK_END))			RWOP_ERR_QUIT(rwops);					
   158         RWOP_ERR_QUIT (rwops);
   122 	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
   159     if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   123 	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
   160         RWOP_ERR_QUIT (rwops);
   124 	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
   161     if (1 != rwops->read (rwops, test_buf, 1, 1))
   125 	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
   162         RWOP_ERR_QUIT (rwops);  /* we are in read/write mode */
   126 	if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);		
   163     if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   127 	if (2!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
   164         RWOP_ERR_QUIT (rwops);
   128 	if (SDL_memcmp(test_buf,"12345678901234567890",20))	RWOP_ERR_QUIT(rwops);
   165     if (20 != rwops->seek (rwops, -7, RW_SEEK_END))
   129 	rwops->close(rwops);
   166         RWOP_ERR_QUIT (rwops);
   130 	printf("test3 OK\n");
   167     if (7 != rwops->read (rwops, test_buf, 1, 7))
       
   168         RWOP_ERR_QUIT (rwops);
       
   169     if (SDL_memcmp (test_buf, "1234567", 7))
       
   170         RWOP_ERR_QUIT (rwops);
       
   171     if (0 != rwops->read (rwops, test_buf, 1, 1))
       
   172         RWOP_ERR_QUIT (rwops);
       
   173     if (0 != rwops->read (rwops, test_buf, 10, 100))
       
   174         RWOP_ERR_QUIT (rwops);
       
   175     if (0 != rwops->seek (rwops, -27, RW_SEEK_CUR))
       
   176         RWOP_ERR_QUIT (rwops);
       
   177     if (2 != rwops->read (rwops, test_buf, 10, 3))
       
   178         RWOP_ERR_QUIT (rwops);
       
   179     if (SDL_memcmp (test_buf, "12345678901234567890", 20))
       
   180         RWOP_ERR_QUIT (rwops);
       
   181     rwops->close (rwops);
       
   182     printf ("test3 OK\n");
   131 
   183 
   132 /* test 4: same in r+ mode */
   184 /* test 4: same in r+ mode */
   133 	rwops = SDL_RWFromFile(FBASENAME1,"rb+"); /* write + read + file must exists, no truncation */		
   185     rwops = SDL_RWFromFile (FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */
   134 	if (!rwops)											RWOP_ERR_QUIT(rwops);
   186     if (!rwops)
   135 	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
   187         RWOP_ERR_QUIT (rwops);
   136 	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
   188     if (1 != rwops->write (rwops, "1234567890", 10, 1))
   137 	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops);		
   189         RWOP_ERR_QUIT (rwops);
   138 	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   190     if (10 != rwops->write (rwops, "1234567890", 1, 10))
   139 	if (1!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); /* we are in read/write mode */
   191         RWOP_ERR_QUIT (rwops);
   140 	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   192     if (7 != rwops->write (rwops, "1234567", 1, 7))
   141 	if (20!=rwops->seek(rwops,-7,RW_SEEK_END))			RWOP_ERR_QUIT(rwops);					
   193         RWOP_ERR_QUIT (rwops);
   142 	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
   194     if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   143 	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
   195         RWOP_ERR_QUIT (rwops);
   144 	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
   196     if (1 != rwops->read (rwops, test_buf, 1, 1))
   145 	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
   197         RWOP_ERR_QUIT (rwops);  /* we are in read/write mode */
   146 	if (0!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);		
   198     if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   147 	if (2!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
   199         RWOP_ERR_QUIT (rwops);
   148 	if (SDL_memcmp(test_buf,"12345678901234567890",20))	RWOP_ERR_QUIT(rwops);
   200     if (20 != rwops->seek (rwops, -7, RW_SEEK_END))
   149 	rwops->close(rwops);
   201         RWOP_ERR_QUIT (rwops);
   150 	printf("test4 OK\n");
   202     if (7 != rwops->read (rwops, test_buf, 1, 7))
       
   203         RWOP_ERR_QUIT (rwops);
       
   204     if (SDL_memcmp (test_buf, "1234567", 7))
       
   205         RWOP_ERR_QUIT (rwops);
       
   206     if (0 != rwops->read (rwops, test_buf, 1, 1))
       
   207         RWOP_ERR_QUIT (rwops);
       
   208     if (0 != rwops->read (rwops, test_buf, 10, 100))
       
   209         RWOP_ERR_QUIT (rwops);
       
   210     if (0 != rwops->seek (rwops, -27, RW_SEEK_CUR))
       
   211         RWOP_ERR_QUIT (rwops);
       
   212     if (2 != rwops->read (rwops, test_buf, 10, 3))
       
   213         RWOP_ERR_QUIT (rwops);
       
   214     if (SDL_memcmp (test_buf, "12345678901234567890", 20))
       
   215         RWOP_ERR_QUIT (rwops);
       
   216     rwops->close (rwops);
       
   217     printf ("test4 OK\n");
   151 
   218 
   152 /* test5 : append mode */
   219 /* test5 : append mode */
   153 	rwops = SDL_RWFromFile(FBASENAME1,"ab+"); /* write + read + append */		
   220     rwops = SDL_RWFromFile (FBASENAME1, "ab+"); /* write + read + append */
   154 	if (!rwops)											RWOP_ERR_QUIT(rwops);
   221     if (!rwops)
   155 	if (1 != rwops->write(rwops,"1234567890",10,1) )	RWOP_ERR_QUIT(rwops);		
   222         RWOP_ERR_QUIT (rwops);
   156 	if (10 != rwops->write(rwops,"1234567890",1,10) )	RWOP_ERR_QUIT(rwops);		
   223     if (1 != rwops->write (rwops, "1234567890", 10, 1))
   157 	if (7 != rwops->write(rwops,"1234567",1,7) )		RWOP_ERR_QUIT(rwops); 	
   224         RWOP_ERR_QUIT (rwops);
   158 	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   225     if (10 != rwops->write (rwops, "1234567890", 1, 10))
   159 	
   226         RWOP_ERR_QUIT (rwops);
   160 	if (1!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops); 
   227     if (7 != rwops->write (rwops, "1234567", 1, 7))
   161 	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);					
   228         RWOP_ERR_QUIT (rwops);
   162 	
   229     if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   163 	if (20+27!=rwops->seek(rwops,-7,RW_SEEK_END))		RWOP_ERR_QUIT(rwops);					
   230         RWOP_ERR_QUIT (rwops);
   164 	if (7!=rwops->read(rwops,test_buf,1,7))				RWOP_ERR_QUIT(rwops);		
   231 
   165 	if (SDL_memcmp(test_buf,"1234567",7))				RWOP_ERR_QUIT(rwops);		
   232     if (1 != rwops->read (rwops, test_buf, 1, 1))
   166 	if (0!=rwops->read(rwops,test_buf,1,1))				RWOP_ERR_QUIT(rwops);		
   233         RWOP_ERR_QUIT (rwops);
   167 	if (0!=rwops->read(rwops,test_buf,10,100))			RWOP_ERR_QUIT(rwops);		
   234     if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
   168 	
   235         RWOP_ERR_QUIT (rwops);
   169 	if (27!=rwops->seek(rwops,-27,RW_SEEK_CUR))			RWOP_ERR_QUIT(rwops);
   236 
   170 	
   237     if (20 + 27 != rwops->seek (rwops, -7, RW_SEEK_END))
   171 	if (0!=rwops->seek(rwops,0L,RW_SEEK_SET))			RWOP_ERR_QUIT(rwops);
   238         RWOP_ERR_QUIT (rwops);
   172 	if (3!=rwops->read(rwops,test_buf,10,3))			RWOP_ERR_QUIT(rwops);				
   239     if (7 != rwops->read (rwops, test_buf, 1, 7))
   173 	if (SDL_memcmp(test_buf,"123456789012345678901234567123",30))	
   240         RWOP_ERR_QUIT (rwops);
   174 														RWOP_ERR_QUIT(rwops);
   241     if (SDL_memcmp (test_buf, "1234567", 7))
   175 	rwops->close(rwops);
   242         RWOP_ERR_QUIT (rwops);
   176 	printf("test5 OK\n");
   243     if (0 != rwops->read (rwops, test_buf, 1, 1))
   177 	cleanup();
   244         RWOP_ERR_QUIT (rwops);
   178 	return 0; /* all ok */
   245     if (0 != rwops->read (rwops, test_buf, 10, 100))
       
   246         RWOP_ERR_QUIT (rwops);
       
   247 
       
   248     if (27 != rwops->seek (rwops, -27, RW_SEEK_CUR))
       
   249         RWOP_ERR_QUIT (rwops);
       
   250 
       
   251     if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET))
       
   252         RWOP_ERR_QUIT (rwops);
       
   253     if (3 != rwops->read (rwops, test_buf, 10, 3))
       
   254         RWOP_ERR_QUIT (rwops);
       
   255     if (SDL_memcmp (test_buf, "123456789012345678901234567123", 30))
       
   256         RWOP_ERR_QUIT (rwops);
       
   257     rwops->close (rwops);
       
   258     printf ("test5 OK\n");
       
   259     cleanup ();
       
   260     return 0;                   /* all ok */
   179 }
   261 }