@@ -94,7 +94,9 @@ void test_fwrite_fread()
94
94
TestFile<FS>::resetFunctionCallHistory ();
95
95
write_ret = std::fwrite (str2, 1 , str2_size, file);
96
96
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
97
+ #if !defined(__MICROLIB)
97
98
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
99
+ #endif
98
100
std::clearerr (file);
99
101
100
102
// ARMCC/IAR returns 0 here instead of number of elements successfully written !!!
@@ -104,7 +106,9 @@ void test_fwrite_fread()
104
106
TestFile<FS>::resetFunctionCallHistory ();
105
107
write_ret = std::fwrite (str1, 1 , str1_size, file);
106
108
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
109
+ #if !defined(__MICROLIB)
107
110
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
111
+ #endif
108
112
TEST_ASSERT_EQUAL_INT (0 , write_ret);
109
113
110
114
std::rewind (file);
@@ -120,7 +124,9 @@ void test_fwrite_fread()
120
124
TestFile<FS>::resetFunctionCallHistory ();
121
125
read_ret = std::fread (read_buf, 1 , str2_size, file);
122
126
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
127
+ #if !defined(__MICROLIB)
123
128
TEST_ASSERT_TRUE (std::feof (file) != 0 );
129
+ #endif
124
130
std::clearerr (file);
125
131
TEST_ASSERT_EQUAL_INT (str2_size - 1 , read_ret);
126
132
TEST_ASSERT_EQUAL_INT (0 , strncmp (str2, read_buf, str2_size - 1 ));
@@ -129,7 +135,9 @@ void test_fwrite_fread()
129
135
TestFile<FS>::resetFunctionCallHistory ();
130
136
read_ret = std::fread (read_buf, 1 , str2_size, file);
131
137
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
138
+ #if !defined(__MICROLIB)
132
139
TEST_ASSERT_TRUE (std::feof (file) != 0 );
140
+ #endif
133
141
TEST_ASSERT_EQUAL_INT (0 , read_ret);
134
142
135
143
std::fclose (file);
@@ -187,7 +195,9 @@ void test_fputc_fgetc()
187
195
TestFile<FS>::resetFunctionCallHistory ();
188
196
ret = std::fputc (char_buf[0 ], file);
189
197
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
198
+ #if !defined(__MICROLIB)
190
199
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
200
+ #endif
191
201
TEST_ASSERT_EQUAL_INT (EOF, ret);
192
202
193
203
std::rewind (file);
@@ -212,7 +222,9 @@ void test_fputc_fgetc()
212
222
TestFile<FS>::resetFunctionCallHistory ();
213
223
ret = std::fgetc (file);
214
224
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
225
+ #if !defined(__MICROLIB)
215
226
TEST_ASSERT_TRUE (std::feof (file) != 0 );
227
+ #endif
216
228
TEST_ASSERT_EQUAL_INT (EOF, ret);
217
229
218
230
std::fclose (file);
@@ -261,15 +273,19 @@ void test_fputs_fgets()
261
273
TestFile<FS>::resetFunctionCallHistory ();
262
274
fputs_ret = std::fputs (str2, file);
263
275
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
276
+ #if !defined(__MICROLIB)
264
277
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
278
+ #endif
265
279
std::clearerr (file);
266
280
TEST_ASSERT_EQUAL_INT (EOF, fputs_ret);
267
281
268
282
// write 3; expected written 0
269
283
TestFile<FS>::resetFunctionCallHistory ();
270
284
fputs_ret = std::fputs (str1, file);
271
285
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
286
+ #if !defined(__MICROLIB)
272
287
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
288
+ #endif
273
289
TEST_ASSERT_EQUAL_INT (EOF, fputs_ret);
274
290
275
291
std::rewind (file);
@@ -285,7 +301,9 @@ void test_fputs_fgets()
285
301
TestFile<FS>::resetFunctionCallHistory ();
286
302
fgets_ret = std::fgets (read_buf, str2_size + 1 , file);
287
303
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
304
+ #if !defined(__MICROLIB)
288
305
TEST_ASSERT_TRUE (std::feof (file) != 0 );
306
+ #endif
289
307
std::clearerr (file);
290
308
TEST_ASSERT_EQUAL_INT (read_buf, fgets_ret);
291
309
TEST_ASSERT_EQUAL_INT (0 , strncmp (read_buf, str2, str2_size - 2 ));
@@ -294,7 +312,9 @@ void test_fputs_fgets()
294
312
TestFile<FS>::resetFunctionCallHistory ();
295
313
fgets_ret = std::fgets (read_buf, str2_size + 1 , file);
296
314
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
315
+ #if !defined(__MICROLIB)
297
316
TEST_ASSERT_TRUE (std::feof (file) != 0 );
317
+ #endif
298
318
TEST_ASSERT_EQUAL_INT (NULL , fgets_ret);
299
319
300
320
std::fclose (file);
@@ -339,6 +359,8 @@ void test_fprintf_fscanf()
339
359
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
340
360
TEST_ASSERT_EQUAL_INT (str1_size, fprintf_ret);
341
361
362
+ #if !defined(__MICROLIB)
363
+ // feof() and ferror() functions are not supported in Microlib.
342
364
// write 3; expected written 2
343
365
TestFile<FS>::resetFunctionCallHistory ();
344
366
fprintf_ret = fprintf (file, " %s" , str2);
@@ -353,7 +375,17 @@ void test_fprintf_fscanf()
353
375
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
354
376
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
355
377
TEST_ASSERT_TRUE (fprintf_ret < 0 );
356
-
378
+ #else
379
+ // Writing remaining available file space of 2 characters
380
+ // to make further fscanf() test to pass.
381
+ // write 2; expected written 2
382
+ TestFile<FS>::resetFunctionCallHistory ();
383
+ fprintf_ret = 0 ;
384
+ fprintf_ret += fprintf (file, " %c" , str2[0 ]);
385
+ fprintf_ret += fprintf (file, " %c" , str2[1 ]);
386
+ TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
387
+ TEST_ASSERT_EQUAL_INT (2 , fprintf_ret);
388
+ #endif
357
389
std::rewind (file);
358
390
359
391
// read 3; expected read 3
@@ -367,16 +399,20 @@ void test_fprintf_fscanf()
367
399
TestFile<FS>::resetFunctionCallHistory ();
368
400
fscanf_ret = fscanf (file, " %3s" , read_buf);
369
401
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
402
+ #if !defined(__MICROLIB)
370
403
TEST_ASSERT_TRUE (std::feof (file) != 0 );
371
404
std::clearerr (file);
405
+ #endif
372
406
TEST_ASSERT_EQUAL_INT (1 , fscanf_ret);
373
407
TEST_ASSERT_EQUAL_INT (0 , strncmp (read_buf, str2, str2_size - 1 ));
374
408
375
409
// read 3; expected read 0
376
410
TestFile<FS>::resetFunctionCallHistory ();
377
411
fscanf_ret = fscanf (file, " %3s" , read_buf);
378
412
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
413
+ #if !defined(__MICROLIB)
379
414
TEST_ASSERT_TRUE (std::feof (file) != 0 );
415
+ #endif
380
416
TEST_ASSERT_EQUAL_INT (EOF, fscanf_ret);
381
417
382
418
std::fclose (file);
0 commit comments