Mercurial > sdl-ios-xcode
comparison test/automated/rwops/rwops.c @ 4451:033c455bbe99
Refactored automated rwops tests so read and write directories can be more easily customized.
The refactored tests were written in recognition that Mac and iPhone current working directories are usually not going to work. Resource directories are in bundles and write directories are restricted to certain areas. In theory, other platforms may have this problem too, hence the refactoring.
Also updated the Xcode iPhone project to use 3.2 as the Base SDK, but 3.1 as the Deployment SDK (for iPhone/iPad compatibility.)
author | Eric Wing <ewing . public |-at-| gmail . com> |
---|---|
date | Sun, 09 May 2010 06:58:30 -0700 |
parents | 8f73f4a3c972 |
children |
comparison
equal
deleted
inserted
replaced
4450:abd88bbaea2a | 4451:033c455bbe99 |
---|---|
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SDL.h" | 10 #include "SDL.h" |
11 #include "../SDL_at.h" | 11 #include "../SDL_at.h" |
12 #if __APPLE__ | 12 #include "TestSupportRWops.h" |
13 #include "Test_rwopsbundlesupport.h" | 13 |
14 #endif | 14 /* Defined in TestSupportRWops implementation to allow flexibility. */ |
15 | 15 extern const char* RWOPS_READ; |
16 #define RWOPS_READ "rwops/read" | 16 extern const char* RWOPS_WRITE; |
17 | |
18 #if __APPLE__ | |
19 #define RWOPS_WRITE "write" | |
20 #else | |
21 #define RWOPS_WRITE "rwops/write" | |
22 #endif | |
23 | 17 |
24 static const char hello_world[] = "Hello World!"; | 18 static const char hello_world[] = "Hello World!"; |
25 | 19 |
26 | 20 |
27 /** | 21 /** |
191 | 185 |
192 /* Begin testcase. */ | 186 /* Begin testcase. */ |
193 SDL_ATbegin( "SDL_RWFromFile" ); | 187 SDL_ATbegin( "SDL_RWFromFile" ); |
194 | 188 |
195 /* Read test. */ | 189 /* Read test. */ |
196 rw = SDL_RWFromFile( RWOPS_READ, "r" ); | 190 rw = TestSupportRWops_OpenRWopsFromReadDir( RWOPS_READ, "r" ); |
197 if (SDL_ATassert( "Opening memory with SDL_RWFromFile '"RWOPS_READ"'", rw != NULL )) | 191 if (SDL_ATassert( "Opening memory with SDL_RWFromFile RWOPS_READ", rw != NULL )) |
198 return; | 192 return; |
199 if (rwops_testGeneric( rw, 0 )) | 193 if (rwops_testGeneric( rw, 0 )) |
200 return; | 194 return; |
201 SDL_FreeRW( rw ); | 195 SDL_FreeRW( rw ); |
202 | 196 |
203 /* Write test. */ | 197 /* Write test. */ |
204 rw = SDL_RWFromFile( RWOPS_WRITE, "w+" ); | 198 rw = TestSupportRWops_OpenRWopsFromWriteDir( RWOPS_WRITE, "w+" ); |
205 if (SDL_ATassert( "Opening memory with SDL_RWFromFile '"RWOPS_WRITE"'", rw != NULL )) | 199 if (SDL_ATassert( "Opening memory with SDL_RWFromFile RWOPS_WRITE", rw != NULL )) |
206 return; | 200 return; |
207 if (rwops_testGeneric( rw, 1 )) | 201 if (rwops_testGeneric( rw, 1 )) |
208 return; | 202 return; |
209 SDL_FreeRW( rw ); | 203 SDL_FreeRW( rw ); |
210 | 204 |
224 | 218 |
225 /* Begin testcase. */ | 219 /* Begin testcase. */ |
226 SDL_ATbegin( "SDL_RWFromFP" ); | 220 SDL_ATbegin( "SDL_RWFromFP" ); |
227 | 221 |
228 /* Run read tests. */ | 222 /* Run read tests. */ |
229 #if __APPLE__ | 223 fp = TestSupportRWops_OpenFPFromReadDir( RWOPS_READ, "r" ); |
230 fp = Test_OpenFPFromBundleOrFallback( RWOPS_READ, "r" ); | 224 if (SDL_ATassert( "Failed to open file 'WOPS_READ", fp != NULL)) |
231 #else | |
232 fp = fopen( RWOPS_READ, "r" ); | |
233 #endif | |
234 if (SDL_ATassert( "Failed to open file '"RWOPS_READ"'", fp != NULL)) | |
235 return; | 225 return; |
236 rw = SDL_RWFromFP( fp, 1 ); | 226 rw = SDL_RWFromFP( fp, 1 ); |
237 if (SDL_ATassert( "Opening memory with SDL_RWFromFP", rw != NULL )) | 227 if (SDL_ATassert( "Opening memory with SDL_RWFromFP", rw != NULL )) |
238 return; | 228 return; |
239 if (rwops_testGeneric( rw, 0 )) | 229 if (rwops_testGeneric( rw, 0 )) |
240 return; | 230 return; |
241 SDL_FreeRW( rw ); | 231 SDL_FreeRW( rw ); |
242 | 232 |
243 /* Run write tests. */ | 233 /* Run write tests. */ |
244 #if __APPLE__ | 234 fp = TestSupportRWops_OpenFPFromWriteDir( RWOPS_WRITE, "w+" ); |
245 fp = Test_OpenFPFromTemporaryDir( RWOPS_WRITE, "w+" ); | 235 if (SDL_ATassert( "Failed to open file RWOPS_WRITE", fp != NULL)) |
246 #else | |
247 fp = fopen( RWOPS_WRITE, "w+" ); | |
248 #endif | |
249 if (SDL_ATassert( "Failed to open file '"RWOPS_WRITE"'", fp != NULL)) | |
250 return; | 236 return; |
251 rw = SDL_RWFromFP( fp, 1 ); | 237 rw = SDL_RWFromFP( fp, 1 ); |
252 if (SDL_ATassert( "Opening memory with SDL_RWFromFP", rw != NULL )) | 238 if (SDL_ATassert( "Opening memory with SDL_RWFromFP", rw != NULL )) |
253 return; | 239 return; |
254 if (rwops_testGeneric( rw, 1 )) | 240 if (rwops_testGeneric( rw, 1 )) |