@@ -94,7 +94,9 @@ void test_fwrite_fread()
9494 TestFile<FS>::resetFunctionCallHistory ();
9595 write_ret = std::fwrite (str2, 1 , str2_size, file);
9696 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
97+ #if !defined(__MICROLIB)
9798 TEST_ASSERT_TRUE (std::ferror (file) != 0 );
99+ #endif
98100 std::clearerr (file);
99101
100102 // ARMCC/IAR returns 0 here instead of number of elements successfully written !!!
@@ -104,7 +106,9 @@ void test_fwrite_fread()
104106 TestFile<FS>::resetFunctionCallHistory ();
105107 write_ret = std::fwrite (str1, 1 , str1_size, file);
106108 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
109+ #if !defined(__MICROLIB)
107110 TEST_ASSERT_TRUE (std::ferror (file) != 0 );
111+ #endif
108112 TEST_ASSERT_EQUAL_INT (0 , write_ret);
109113
110114 std::rewind (file);
@@ -120,7 +124,9 @@ void test_fwrite_fread()
120124 TestFile<FS>::resetFunctionCallHistory ();
121125 read_ret = std::fread (read_buf, 1 , str2_size, file);
122126 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
127+ #if !defined(__MICROLIB)
123128 TEST_ASSERT_TRUE (std::feof (file) != 0 );
129+ #endif
124130 std::clearerr (file);
125131 TEST_ASSERT_EQUAL_INT (str2_size - 1 , read_ret);
126132 TEST_ASSERT_EQUAL_INT (0 , strncmp (str2, read_buf, str2_size - 1 ));
@@ -129,7 +135,9 @@ void test_fwrite_fread()
129135 TestFile<FS>::resetFunctionCallHistory ();
130136 read_ret = std::fread (read_buf, 1 , str2_size, file);
131137 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
138+ #if !defined(__MICROLIB)
132139 TEST_ASSERT_TRUE (std::feof (file) != 0 );
140+ #endif
133141 TEST_ASSERT_EQUAL_INT (0 , read_ret);
134142
135143 std::fclose (file);
@@ -187,7 +195,9 @@ void test_fputc_fgetc()
187195 TestFile<FS>::resetFunctionCallHistory ();
188196 ret = std::fputc (char_buf[0 ], file);
189197 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
198+ #if !defined(__MICROLIB)
190199 TEST_ASSERT_TRUE (std::ferror (file) != 0 );
200+ #endif
191201 TEST_ASSERT_EQUAL_INT (EOF, ret);
192202
193203 std::rewind (file);
@@ -212,7 +222,9 @@ void test_fputc_fgetc()
212222 TestFile<FS>::resetFunctionCallHistory ();
213223 ret = std::fgetc (file);
214224 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
225+ #if !defined(__MICROLIB)
215226 TEST_ASSERT_TRUE (std::feof (file) != 0 );
227+ #endif
216228 TEST_ASSERT_EQUAL_INT (EOF, ret);
217229
218230 std::fclose (file);
@@ -261,15 +273,19 @@ void test_fputs_fgets()
261273 TestFile<FS>::resetFunctionCallHistory ();
262274 fputs_ret = std::fputs (str2, file);
263275 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
276+ #if !defined(__MICROLIB)
264277 TEST_ASSERT_TRUE (std::ferror (file) != 0 );
278+ #endif
265279 std::clearerr (file);
266280 TEST_ASSERT_EQUAL_INT (EOF, fputs_ret);
267281
268282 // write 3; expected written 0
269283 TestFile<FS>::resetFunctionCallHistory ();
270284 fputs_ret = std::fputs (str1, file);
271285 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
286+ #if !defined(__MICROLIB)
272287 TEST_ASSERT_TRUE (std::ferror (file) != 0 );
288+ #endif
273289 TEST_ASSERT_EQUAL_INT (EOF, fputs_ret);
274290
275291 std::rewind (file);
@@ -285,7 +301,9 @@ void test_fputs_fgets()
285301 TestFile<FS>::resetFunctionCallHistory ();
286302 fgets_ret = std::fgets (read_buf, str2_size + 1 , file);
287303 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
304+ #if !defined(__MICROLIB)
288305 TEST_ASSERT_TRUE (std::feof (file) != 0 );
306+ #endif
289307 std::clearerr (file);
290308 TEST_ASSERT_EQUAL_INT (read_buf, fgets_ret);
291309 TEST_ASSERT_EQUAL_INT (0 , strncmp (read_buf, str2, str2_size - 2 ));
@@ -294,7 +312,9 @@ void test_fputs_fgets()
294312 TestFile<FS>::resetFunctionCallHistory ();
295313 fgets_ret = std::fgets (read_buf, str2_size + 1 , file);
296314 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
315+ #if !defined(__MICROLIB)
297316 TEST_ASSERT_TRUE (std::feof (file) != 0 );
317+ #endif
298318 TEST_ASSERT_EQUAL_INT (NULL , fgets_ret);
299319
300320 std::fclose (file);
@@ -339,6 +359,8 @@ void test_fprintf_fscanf()
339359 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
340360 TEST_ASSERT_EQUAL_INT (str1_size, fprintf_ret);
341361
362+ #if !defined(__MICROLIB)
363+ // feof() and ferror() functions are not supported in Microlib.
342364 // write 3; expected written 2
343365 TestFile<FS>::resetFunctionCallHistory ();
344366 fprintf_ret = fprintf (file, " %s" , str2);
@@ -353,7 +375,17 @@ void test_fprintf_fscanf()
353375 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
354376 TEST_ASSERT_TRUE (std::ferror (file) != 0 );
355377 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
357389 std::rewind (file);
358390
359391 // read 3; expected read 3
@@ -367,16 +399,20 @@ void test_fprintf_fscanf()
367399 TestFile<FS>::resetFunctionCallHistory ();
368400 fscanf_ret = fscanf (file, " %3s" , read_buf);
369401 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
402+ #if !defined(__MICROLIB)
370403 TEST_ASSERT_TRUE (std::feof (file) != 0 );
371404 std::clearerr (file);
405+ #endif
372406 TEST_ASSERT_EQUAL_INT (1 , fscanf_ret);
373407 TEST_ASSERT_EQUAL_INT (0 , strncmp (read_buf, str2, str2_size - 1 ));
374408
375409 // read 3; expected read 0
376410 TestFile<FS>::resetFunctionCallHistory ();
377411 fscanf_ret = fscanf (file, " %3s" , read_buf);
378412 TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
413+ #if !defined(__MICROLIB)
379414 TEST_ASSERT_TRUE (std::feof (file) != 0 );
415+ #endif
380416 TEST_ASSERT_EQUAL_INT (EOF, fscanf_ret);
381417
382418 std::fclose (file);
0 commit comments