Skip to content

Commit af935e5

Browse files
committed
update test
1 parent 1f4ab58 commit af935e5

File tree

1 file changed

+195
-13
lines changed

1 file changed

+195
-13
lines changed

test/test_file_seek_tell.c

Lines changed: 195 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include "test.h"
32
#include "fluidsynth.h"
43
#include "sfloader/fluid_sfont.h"
@@ -22,6 +21,9 @@ int main(void)
2221
void * file = fcbs->fopen(TEST_SOUNDFONT);
2322
TEST_ASSERT(file != NULL);
2423

24+
pos = fcbs->ftell(file);
25+
TEST_ASSERT(pos == 0);
26+
2527
TEST_ASSERT(fcbs->fseek(file, 0, SEEK_END) == FLUID_OK);
2628
size = fcbs->ftell(file);
2729
TEST_ASSERT(size == 314640);
@@ -30,32 +32,212 @@ int main(void)
3032
pos = fcbs->ftell(file);
3133
TEST_ASSERT(pos == 0);
3234

33-
TEST_ASSERT(fcbs->fseek(file, 464, SEEK_SET) == FLUID_OK);
34-
pos = fcbs->ftell(file);
35-
TEST_ASSERT(pos == 464);
35+
{
36+
unsigned char buf[1024];
3637

37-
TEST_ASSERT(fcbs->fseek(file, 0, SEEK_CUR) == FLUID_OK);
38-
pos = fcbs->ftell(file);
39-
TEST_ASSERT(pos == 464);
38+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
39+
pos = fcbs->ftell(file);
40+
TEST_ASSERT(pos == 4);
41+
42+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
43+
pos = fcbs->ftell(file);
44+
TEST_ASSERT(pos == 8);
45+
46+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
47+
pos = fcbs->ftell(file);
48+
TEST_ASSERT(pos == 12);
49+
50+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
51+
pos = fcbs->ftell(file);
52+
TEST_ASSERT(pos == 16);
53+
54+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
55+
pos = fcbs->ftell(file);
56+
TEST_ASSERT(pos == 20);
57+
58+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
59+
pos = fcbs->ftell(file);
60+
TEST_ASSERT(pos == 24);
61+
62+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
63+
pos = fcbs->ftell(file);
64+
TEST_ASSERT(pos == 28);
65+
66+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
67+
pos = fcbs->ftell(file);
68+
TEST_ASSERT(pos == 32);
69+
70+
TEST_ASSERT(fcbs->fread(buf, 2, file) == FLUID_OK);
71+
pos = fcbs->ftell(file);
72+
TEST_ASSERT(pos == 34);
73+
74+
TEST_ASSERT(fcbs->fread(buf, 2, file) == FLUID_OK);
75+
pos = fcbs->ftell(file);
76+
TEST_ASSERT(pos == 36);
77+
78+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
79+
pos = fcbs->ftell(file);
80+
TEST_ASSERT(pos == 40);
81+
82+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
83+
pos = fcbs->ftell(file);
84+
TEST_ASSERT(pos == 44);
85+
86+
TEST_ASSERT(fcbs->fread(buf, 28, file) == FLUID_OK);
87+
pos = fcbs->ftell(file);
88+
TEST_ASSERT(pos == 72);
89+
90+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
91+
pos = fcbs->ftell(file);
92+
TEST_ASSERT(pos == 76);
93+
94+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
95+
pos = fcbs->ftell(file);
96+
TEST_ASSERT(pos == 80);
97+
98+
TEST_ASSERT(fcbs->fread(buf, 8, file) == FLUID_OK);
99+
pos = fcbs->ftell(file);
100+
TEST_ASSERT(pos == 88);
101+
102+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
103+
pos = fcbs->ftell(file);
104+
TEST_ASSERT(pos == 92);
105+
106+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
107+
pos = fcbs->ftell(file);
108+
TEST_ASSERT(pos == 96);
109+
110+
TEST_ASSERT(fcbs->fread(buf, 6, file) == FLUID_OK);
111+
pos = fcbs->ftell(file);
112+
TEST_ASSERT(pos == 102);
113+
114+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
115+
pos = fcbs->ftell(file);
116+
TEST_ASSERT(pos == 106);
117+
118+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
119+
pos = fcbs->ftell(file);
120+
TEST_ASSERT(pos == 110);
121+
122+
TEST_ASSERT(fcbs->fread(buf, 2, file) == FLUID_OK);
123+
pos = fcbs->ftell(file);
124+
TEST_ASSERT(pos == 112);
125+
126+
TEST_ASSERT(fcbs->fread(buf, 2, file) == FLUID_OK);
127+
pos = fcbs->ftell(file);
128+
TEST_ASSERT(pos == 114);
129+
130+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
131+
pos = fcbs->ftell(file);
132+
TEST_ASSERT(pos == 118);
133+
134+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
135+
pos = fcbs->ftell(file);
136+
TEST_ASSERT(pos == 122);
137+
138+
TEST_ASSERT(fcbs->fread(buf, 8, file) == FLUID_OK);
139+
pos = fcbs->ftell(file);
140+
TEST_ASSERT(pos == 130);
141+
142+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
143+
pos = fcbs->ftell(file);
144+
TEST_ASSERT(pos == 134);
145+
146+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
147+
pos = fcbs->ftell(file);
148+
TEST_ASSERT(pos == 138);
149+
150+
TEST_ASSERT(fcbs->fread(buf, 12, file) == FLUID_OK);
151+
pos = fcbs->ftell(file);
152+
TEST_ASSERT(pos == 150);
153+
154+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
155+
pos = fcbs->ftell(file);
156+
TEST_ASSERT(pos == 154);
157+
158+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
159+
pos = fcbs->ftell(file);
160+
TEST_ASSERT(pos == 158);
161+
162+
TEST_ASSERT(fcbs->fread(buf, 24, file) == FLUID_OK);
163+
pos = fcbs->ftell(file);
164+
TEST_ASSERT(pos == 182);
165+
166+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
167+
pos = fcbs->ftell(file);
168+
TEST_ASSERT(pos == 186);
169+
170+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
171+
pos = fcbs->ftell(file);
172+
TEST_ASSERT(pos == 190);
173+
174+
TEST_ASSERT(fcbs->fread(buf, 14, file) == FLUID_OK);
175+
pos = fcbs->ftell(file);
176+
TEST_ASSERT(pos == 204);
177+
178+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
179+
pos = fcbs->ftell(file);
180+
TEST_ASSERT(pos == 208);
181+
182+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
183+
pos = fcbs->ftell(file);
184+
TEST_ASSERT(pos == 212);
185+
186+
TEST_ASSERT(fcbs->fread(buf, 184, file) == FLUID_OK);
187+
pos = fcbs->ftell(file);
188+
TEST_ASSERT(pos == 396);
189+
190+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
191+
pos = fcbs->ftell(file);
192+
TEST_ASSERT(pos == 400);
193+
194+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
195+
pos = fcbs->ftell(file);
196+
TEST_ASSERT(pos == 404);
197+
198+
TEST_ASSERT(fcbs->fread(buf, 40, file) == FLUID_OK);
199+
pos = fcbs->ftell(file);
200+
TEST_ASSERT(pos == 444);
201+
202+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
203+
pos = fcbs->ftell(file);
204+
TEST_ASSERT(pos == 448);
205+
206+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
207+
pos = fcbs->ftell(file);
208+
TEST_ASSERT(pos == 452);
209+
210+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
211+
pos = fcbs->ftell(file);
212+
TEST_ASSERT(pos == 456);
213+
214+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
215+
pos = fcbs->ftell(file);
216+
TEST_ASSERT(pos == 460);
217+
218+
TEST_ASSERT(fcbs->fread(buf, 4, file) == FLUID_OK);
219+
pos = fcbs->ftell(file);
220+
TEST_ASSERT(pos == 464);
221+
}
40222

41223
TEST_ASSERT(fcbs->fseek(file, 252534, SEEK_CUR) == FLUID_OK);
42224
pos = fcbs->ftell(file);
43225
TEST_ASSERT(pos == 252534 + 464);
44226

227+
TEST_ASSERT(fcbs->fseek(file, 0, SEEK_CUR) == FLUID_OK);
228+
pos = fcbs->ftell(file);
229+
TEST_ASSERT(pos == 252534 + 464);
230+
45231
TEST_ASSERT(fcbs->fseek(file, -252534, SEEK_CUR) == FLUID_OK);
46232
pos = fcbs->ftell(file);
47233
TEST_ASSERT(pos == 464);
48234

49-
TEST_ASSERT(fcbs->fseek(file, 0, SEEK_END) == FLUID_OK);
50-
size = fcbs->ftell(file);
51-
TEST_ASSERT(size == 314640);
52-
53235
TEST_ASSERT(fcbs->fseek(file, 0, SEEK_SET) == FLUID_OK);
54236
pos = fcbs->ftell(file);
55237
TEST_ASSERT(pos == 0);
56238

57-
fcbs->fclose(file);
239+
TEST_ASSERT(fcbs->fclose(file) == FLUID_OK);
58240
delete_fluid_sfloader(loader);
59241

60242
return EXIT_SUCCESS;
61-
}
243+
}

0 commit comments

Comments
 (0)