annotate test/testfile.c @ 1960:118daa3a24cc

Added numlock support
author Sam Lantinga <slouken@libsdl.org>
date Sun, 30 Jul 2006 06:11:24 +0000
parents c121d94672cb
children 891ed60fcaa9
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
1484
b2b476a4a73c Added documentation on how to build a completely useless SDL library. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1454
diff changeset
4 #include <stdlib.h>
1843
c2c327e8e781 Needed unistd.h for unlink()
Sam Lantinga <slouken@libsdl.org>
parents: 1484
diff changeset
5 #include <unistd.h>
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 #include "SDL.h"
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 #include "SDL_endian.h"
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10
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
11 #include <stdio.h>
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 /* WARNING ! those 2 files will be destroyed by this test program */
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
14 #define FBASENAME1 "sdldata1" /* this file will be created during tests */
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
15 #define FBASENAME2 "sdldata2" /* this file should not exists before starting test */
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 #ifndef NULL
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 #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
20 #endif
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21
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
22 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
23 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
24 {
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25
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
26 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
27 unlink(FBASENAME2);
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
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
30 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
31 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
32 {
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
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 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
35 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
36 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
37 }
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 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
39 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
40 }
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #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
43
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45
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
46 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
47 main(int argc, char *argv[])
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 {
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
49 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
50 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
51
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
52 cleanup();
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 /* 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
55
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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71 printf("test1 OK\n");
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 /* 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
74 /* 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
75 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
76
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 */
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
78 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
79 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
80 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
81 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
82 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
83 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
84 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
85 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
86 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
87 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
88 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
89 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
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->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
93 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
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 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
104 printf("test2 OK\n");
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 /* test 3 : creation, writing , reading, seeking,
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 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
108 */
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
109 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
110 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
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 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
119 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
120 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
121 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
122 rwops->close(rwops);
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123
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
124 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
125 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
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 (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
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 (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
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 (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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146 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
147 rwops->close(rwops);
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 /* 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181 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
182 printf("test3 OK\n");
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 /* 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
185 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
186 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
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 (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
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 (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
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 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
193 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
194 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
195 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
196 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
197 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
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 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
206 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
207 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
208 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
209 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
210 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
211 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
212 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
213 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
214 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
215 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
216 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
217 printf("test4 OK\n");
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 /* 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
220 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
221 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
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 (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
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 (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
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 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
228 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
229 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
230 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
231
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 (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
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 (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
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
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 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
238 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
239 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
240 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
241 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
242 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
243 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
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->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
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 (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
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
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 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 return 0; /* all ok */
1453
2eb75f8a32ca Date: Mon, 27 Feb 2006 17:01:43 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 }