Mercurial > sdl-ios-xcode
annotate test/testfile.c @ 5144:31e7f523ab3d
Making the API simpler, texture color and alpha modulation are supported by all renderers.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 31 Jan 2011 23:37:30 -0800 |
parents | e8916fe9cfc8 |
children |
rev | line source |
---|---|
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 /* sanity tests on SDL_rwops.c (usefull for alternative implementations of stdio rwops) */ |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 |
5062 | 4 // quiet windows compiler warnings |
4884
27ab20a36eba
- added directx include path to VS2008 solution
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
2765
diff
changeset
|
5 #define _CRT_NONSTDC_NO_WARNINGS |
27ab20a36eba
- added directx include path to VS2008 solution
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
2765
diff
changeset
|
6 |
1484
b2b476a4a73c
Added documentation on how to build a completely useless SDL library. :)
Sam Lantinga <slouken@libsdl.org>
parents:
1454
diff
changeset
|
7 #include <stdlib.h> |
2099
891ed60fcaa9
Merged r2999:3000 from branches/SDL-1.2: Visual Studio compilation fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
8 |
891ed60fcaa9
Merged r2999:3000 from branches/SDL-1.2: Visual Studio compilation fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
9 #ifndef _MSC_VER |
1843
c2c327e8e781
Needed unistd.h for unlink()
Sam Lantinga <slouken@libsdl.org>
parents:
1484
diff
changeset
|
10 #include <unistd.h> |
2099
891ed60fcaa9
Merged r2999:3000 from branches/SDL-1.2: Visual Studio compilation fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
11 #endif |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 #include "SDL.h" |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 #include "SDL_endian.h" |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
17 #include <stdio.h> |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 /* WARNING ! those 2 files will be destroyed by this test program */ |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2099
diff
changeset
|
20 |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2099
diff
changeset
|
21 #ifdef __IPHONEOS__ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2099
diff
changeset
|
22 #define FBASENAME1 "../Documents/sdldata1" /* this file will be created during tests */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2099
diff
changeset
|
23 #define FBASENAME2 "../Documents/sdldata2" /* this file should not exist before starting test */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2099
diff
changeset
|
24 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
25 #define FBASENAME1 "sdldata1" /* this file will be created during tests */ |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2099
diff
changeset
|
26 #define FBASENAME2 "sdldata2" /* this file should not exist before starting test */ |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2099
diff
changeset
|
27 #endif |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #ifndef NULL |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #define NULL ((void *)0) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
31 #endif |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
33 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
34 cleanup(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
35 { |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
37 unlink(FBASENAME1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
38 unlink(FBASENAME2); |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 } |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
41 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
42 rwops_error_quit(unsigned line, SDL_RWops * rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
43 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
44 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
45 printf("testfile.c(%d): failed\n", line); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
46 if (rwops) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
47 rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
48 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
49 cleanup(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
50 exit(1); /* quit with rwops error (test failed) */ |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 } |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 #define RWOP_ERR_QUIT(x) rwops_error_quit( __LINE__, (x) ) |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
57 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
58 main(int argc, char *argv[]) |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
60 SDL_RWops *rwops = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
61 char test_buf[30]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
62 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
63 cleanup(); |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 /* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
66 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
67 rwops = SDL_RWFromFile(NULL, NULL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
68 if (rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
69 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
70 rwops = SDL_RWFromFile(NULL, "ab+"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
71 if (rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
72 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
73 rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
74 if (rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
75 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
76 rwops = SDL_RWFromFile("something", ""); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
77 if (rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
78 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
79 rwops = SDL_RWFromFile("something", NULL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
80 if (rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
81 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
82 printf("test1 OK\n"); |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 /* test 2 : check that inexistant file is not successfully opened/created when required */ |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 /* modes : r, r+ implie that file MUST exist |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 modes : a, a+, w, w+ checks that it succeeds (file may not exists) |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
89 rwops = SDL_RWFromFile(FBASENAME2, "rb"); /* this file doesn't exist that call must fail */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
90 if (rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
91 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
92 rwops = SDL_RWFromFile(FBASENAME2, "rb+"); /* this file doesn't exist that call must fail */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
93 if (rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
94 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
95 rwops = SDL_RWFromFile(FBASENAME2, "wb"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
96 if (!rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
97 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
98 rwops->close(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
99 unlink(FBASENAME2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
100 rwops = SDL_RWFromFile(FBASENAME2, "wb+"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
101 if (!rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
102 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
103 rwops->close(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
104 unlink(FBASENAME2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
105 rwops = SDL_RWFromFile(FBASENAME2, "ab"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
106 if (!rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
107 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
108 rwops->close(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
109 unlink(FBASENAME2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
110 rwops = SDL_RWFromFile(FBASENAME2, "ab+"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
111 if (!rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
112 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
113 rwops->close(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
114 unlink(FBASENAME2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
115 printf("test2 OK\n"); |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 /* test 3 : creation, writing , reading, seeking, |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 test : w mode, r mode, w+ mode |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
120 rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
121 if (!rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
122 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
123 if (1 != rwops->write(rwops, "1234567890", 10, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
124 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
125 if (10 != rwops->write(rwops, "1234567890", 1, 10)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
126 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
127 if (7 != rwops->write(rwops, "1234567", 1, 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
128 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
129 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
130 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
131 if (0 != rwops->read(rwops, test_buf, 1, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
132 RWOP_ERR_QUIT(rwops); /* we are in write only mode */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
133 rwops->close(rwops); |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
135 rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exists */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
136 if (!rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
137 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
138 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
139 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
140 if (20 != rwops->seek(rwops, -7, RW_SEEK_END)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
141 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
142 if (7 != rwops->read(rwops, test_buf, 1, 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
143 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
144 if (SDL_memcmp(test_buf, "1234567", 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
145 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
146 if (0 != rwops->read(rwops, test_buf, 1, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
147 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
148 if (0 != rwops->read(rwops, test_buf, 10, 100)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
149 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
150 if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
151 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
152 if (2 != rwops->read(rwops, test_buf, 10, 3)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
153 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
154 if (SDL_memcmp(test_buf, "12345678901234567890", 20)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
155 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
156 if (0 != rwops->write(rwops, test_buf, 1, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
157 RWOP_ERR_QUIT(rwops); /* readonly mode */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
158 rwops->close(rwops); |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 /* test 3: same with w+ mode */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
161 rwops = SDL_RWFromFile(FBASENAME1, "wb+"); /* write + read + truncation */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
162 if (!rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
163 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
164 if (1 != rwops->write(rwops, "1234567890", 10, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
165 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
166 if (10 != rwops->write(rwops, "1234567890", 1, 10)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
167 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
168 if (7 != rwops->write(rwops, "1234567", 1, 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
169 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
170 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
171 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
172 if (1 != rwops->read(rwops, test_buf, 1, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
173 RWOP_ERR_QUIT(rwops); /* we are in read/write mode */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
174 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
175 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
176 if (20 != rwops->seek(rwops, -7, RW_SEEK_END)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
177 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
178 if (7 != rwops->read(rwops, test_buf, 1, 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
179 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
180 if (SDL_memcmp(test_buf, "1234567", 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
181 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
182 if (0 != rwops->read(rwops, test_buf, 1, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
183 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
184 if (0 != rwops->read(rwops, test_buf, 10, 100)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
185 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
186 if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
187 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
188 if (2 != rwops->read(rwops, test_buf, 10, 3)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
189 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
190 if (SDL_memcmp(test_buf, "12345678901234567890", 20)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
191 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
192 rwops->close(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
193 printf("test3 OK\n"); |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 /* test 4: same in r+ mode */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
196 rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
197 if (!rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
198 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
199 if (1 != rwops->write(rwops, "1234567890", 10, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
200 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
201 if (10 != rwops->write(rwops, "1234567890", 1, 10)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
202 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
203 if (7 != rwops->write(rwops, "1234567", 1, 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
204 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
205 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
206 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
207 if (1 != rwops->read(rwops, test_buf, 1, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
208 RWOP_ERR_QUIT(rwops); /* we are in read/write mode */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
209 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
210 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
211 if (20 != rwops->seek(rwops, -7, RW_SEEK_END)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
212 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
213 if (7 != rwops->read(rwops, test_buf, 1, 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
214 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
215 if (SDL_memcmp(test_buf, "1234567", 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
216 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
217 if (0 != rwops->read(rwops, test_buf, 1, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
218 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
219 if (0 != rwops->read(rwops, test_buf, 10, 100)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
220 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
221 if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
222 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
223 if (2 != rwops->read(rwops, test_buf, 10, 3)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
224 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
225 if (SDL_memcmp(test_buf, "12345678901234567890", 20)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
226 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
227 rwops->close(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
228 printf("test4 OK\n"); |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 |
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 /* test5 : append mode */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
231 rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
232 if (!rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
233 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
234 if (1 != rwops->write(rwops, "1234567890", 10, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
235 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
236 if (10 != rwops->write(rwops, "1234567890", 1, 10)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
237 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
238 if (7 != rwops->write(rwops, "1234567", 1, 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
239 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
240 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
241 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
242 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
243 if (1 != rwops->read(rwops, test_buf, 1, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
244 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
245 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
246 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
247 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
248 if (20 + 27 != rwops->seek(rwops, -7, RW_SEEK_END)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
249 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
250 if (7 != rwops->read(rwops, test_buf, 1, 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
251 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
252 if (SDL_memcmp(test_buf, "1234567", 7)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
253 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
254 if (0 != rwops->read(rwops, test_buf, 1, 1)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
255 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
256 if (0 != rwops->read(rwops, test_buf, 10, 100)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
257 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
258 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
259 if (27 != rwops->seek(rwops, -27, RW_SEEK_CUR)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
260 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
261 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
262 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
263 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
264 if (3 != rwops->read(rwops, test_buf, 10, 3)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
265 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
266 if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
267 RWOP_ERR_QUIT(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
268 rwops->close(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
269 printf("test5 OK\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
270 cleanup(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1843
diff
changeset
|
271 return 0; /* all ok */ |
1453
2eb75f8a32ca
Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 } |