Lines Matching refs:rwops
13 /* sanity tests on SDL_rwops.c (usefull for alternative implementations of stdio rwops) */
52 rwops_error_quit(unsigned line, SDL_RWops * rwops)
55 if (rwops) {
56 rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */
59 exit(1); /* quit with rwops error (test failed) */
69 SDL_RWops *rwops = NULL;
79 rwops = SDL_RWFromFile(NULL, NULL);
80 if (rwops)
81 RWOP_ERR_QUIT(rwops);
82 rwops = SDL_RWFromFile(NULL, "ab+");
83 if (rwops)
84 RWOP_ERR_QUIT(rwops);
85 rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj");
86 if (rwops)
87 RWOP_ERR_QUIT(rwops);
88 rwops = SDL_RWFromFile("something", "");
89 if (rwops)
90 RWOP_ERR_QUIT(rwops);
91 rwops = SDL_RWFromFile("something", NULL);
92 if (rwops)
93 RWOP_ERR_QUIT(rwops);
101 rwops = SDL_RWFromFile(FBASENAME2, "rb"); /* this file doesn't exist that call must fail */
102 if (rwops)
103 RWOP_ERR_QUIT(rwops);
104 rwops = SDL_RWFromFile(FBASENAME2, "rb+"); /* this file doesn't exist that call must fail */
105 if (rwops)
106 RWOP_ERR_QUIT(rwops);
107 rwops = SDL_RWFromFile(FBASENAME2, "wb");
108 if (!rwops)
109 RWOP_ERR_QUIT(rwops);
110 rwops->close(rwops);
112 rwops = SDL_RWFromFile(FBASENAME2, "wb+");
113 if (!rwops)
114 RWOP_ERR_QUIT(rwops);
115 rwops->close(rwops);
117 rwops = SDL_RWFromFile(FBASENAME2, "ab");
118 if (!rwops)
119 RWOP_ERR_QUIT(rwops);
120 rwops->close(rwops);
122 rwops = SDL_RWFromFile(FBASENAME2, "ab+");
123 if (!rwops)
124 RWOP_ERR_QUIT(rwops);
125 rwops->close(rwops);
132 rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */
133 if (!rwops)
134 RWOP_ERR_QUIT(rwops);
135 if (1 != rwops->write(rwops, "1234567890", 10, 1))
136 RWOP_ERR_QUIT(rwops);
137 if (10 != rwops->write(rwops, "1234567890", 1, 10))
138 RWOP_ERR_QUIT(rwops);
139 if (7 != rwops->write(rwops, "1234567", 1, 7))
140 RWOP_ERR_QUIT(rwops);
141 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
142 RWOP_ERR_QUIT(rwops);
143 if (0 != rwops->read(rwops, test_buf, 1, 1))
144 RWOP_ERR_QUIT(rwops); /* we are in write only mode */
145 rwops->close(rwops);
147 rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exists */
148 if (!rwops)
149 RWOP_ERR_QUIT(rwops);
150 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
151 RWOP_ERR_QUIT(rwops);
152 if (20 != rwops->seek(rwops, -7, RW_SEEK_END))
153 RWOP_ERR_QUIT(rwops);
154 if (7 != rwops->read(rwops, test_buf, 1, 7))
155 RWOP_ERR_QUIT(rwops);
157 RWOP_ERR_QUIT(rwops);
158 if (0 != rwops->read(rwops, test_buf, 1, 1))
159 RWOP_ERR_QUIT(rwops);
160 if (0 != rwops->read(rwops, test_buf, 10, 100))
161 RWOP_ERR_QUIT(rwops);
162 if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR))
163 RWOP_ERR_QUIT(rwops);
164 if (2 != rwops->read(rwops, test_buf, 10, 3))
165 RWOP_ERR_QUIT(rwops);
167 RWOP_ERR_QUIT(rwops);
168 if (0 != rwops->write(rwops, test_buf, 1, 1))
169 RWOP_ERR_QUIT(rwops); /* readonly mode */
170 rwops->close(rwops);
173 rwops = SDL_RWFromFile(FBASENAME1, "wb+"); /* write + read + truncation */
174 if (!rwops)
175 RWOP_ERR_QUIT(rwops);
176 if (1 != rwops->write(rwops, "1234567890", 10, 1))
177 RWOP_ERR_QUIT(rwops);
178 if (10 != rwops->write(rwops, "1234567890", 1, 10))
179 RWOP_ERR_QUIT(rwops);
180 if (7 != rwops->write(rwops, "1234567", 1, 7))
181 RWOP_ERR_QUIT(rwops);
182 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
183 RWOP_ERR_QUIT(rwops);
184 if (1 != rwops->read(rwops, test_buf, 1, 1))
185 RWOP_ERR_QUIT(rwops); /* we are in read/write mode */
186 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
187 RWOP_ERR_QUIT(rwops);
188 if (20 != rwops->seek(rwops, -7, RW_SEEK_END))
189 RWOP_ERR_QUIT(rwops);
190 if (7 != rwops->read(rwops, test_buf, 1, 7))
191 RWOP_ERR_QUIT(rwops);
193 RWOP_ERR_QUIT(rwops);
194 if (0 != rwops->read(rwops, test_buf, 1, 1))
195 RWOP_ERR_QUIT(rwops);
196 if (0 != rwops->read(rwops, test_buf, 10, 100))
197 RWOP_ERR_QUIT(rwops);
198 if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR))
199 RWOP_ERR_QUIT(rwops);
200 if (2 != rwops->read(rwops, test_buf, 10, 3))
201 RWOP_ERR_QUIT(rwops);
203 RWOP_ERR_QUIT(rwops);
204 rwops->close(rwops);
208 rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */
209 if (!rwops)
210 RWOP_ERR_QUIT(rwops);
211 if (1 != rwops->write(rwops, "1234567890", 10, 1))
212 RWOP_ERR_QUIT(rwops);
213 if (10 != rwops->write(rwops, "1234567890", 1, 10))
214 RWOP_ERR_QUIT(rwops);
215 if (7 != rwops->write(rwops, "1234567", 1, 7))
216 RWOP_ERR_QUIT(rwops);
217 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
218 RWOP_ERR_QUIT(rwops);
219 if (1 != rwops->read(rwops, test_buf, 1, 1))
220 RWOP_ERR_QUIT(rwops); /* we are in read/write mode */
221 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
222 RWOP_ERR_QUIT(rwops);
223 if (20 != rwops->seek(rwops, -7, RW_SEEK_END))
224 RWOP_ERR_QUIT(rwops);
225 if (7 != rwops->read(rwops, test_buf, 1, 7))
226 RWOP_ERR_QUIT(rwops);
228 RWOP_ERR_QUIT(rwops);
229 if (0 != rwops->read(rwops, test_buf, 1, 1))
230 RWOP_ERR_QUIT(rwops);
231 if (0 != rwops->read(rwops, test_buf, 10, 100))
232 RWOP_ERR_QUIT(rwops);
233 if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR))
234 RWOP_ERR_QUIT(rwops);
235 if (2 != rwops->read(rwops, test_buf, 10, 3))
236 RWOP_ERR_QUIT(rwops);
238 RWOP_ERR_QUIT(rwops);
239 rwops->close(rwops);
243 rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */
244 if (!rwops)
245 RWOP_ERR_QUIT(rwops);
246 if (1 != rwops->write(rwops, "1234567890", 10, 1))
247 RWOP_ERR_QUIT(rwops);
248 if (10 != rwops->write(rwops, "1234567890", 1, 10))
249 RWOP_ERR_QUIT(rwops);
250 if (7 != rwops->write(rwops, "1234567", 1, 7))
251 RWOP_ERR_QUIT(rwops);
252 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
253 RWOP_ERR_QUIT(rwops);
255 if (1 != rwops->read(rwops, test_buf, 1, 1))
256 RWOP_ERR_QUIT(rwops);
257 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
258 RWOP_ERR_QUIT(rwops);
260 if (20 + 27 != rwops->seek(rwops, -7, RW_SEEK_END))
261 RWOP_ERR_QUIT(rwops);
262 if (7 != rwops->read(rwops, test_buf, 1, 7))
263 RWOP_ERR_QUIT(rwops);
265 RWOP_ERR_QUIT(rwops);
266 if (0 != rwops->read(rwops, test_buf, 1, 1))
267 RWOP_ERR_QUIT(rwops);
268 if (0 != rwops->read(rwops, test_buf, 10, 100))
269 RWOP_ERR_QUIT(rwops);
271 if (27 != rwops->seek(rwops, -27, RW_SEEK_CUR))
272 RWOP_ERR_QUIT(rwops);
274 if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET))
275 RWOP_ERR_QUIT(rwops);
276 if (3 != rwops->read(rwops, test_buf, 10, 3))
277 RWOP_ERR_QUIT(rwops);
279 RWOP_ERR_QUIT(rwops);
280 rwops->close(rwops);