@@ -90,25 +90,22 @@ void test_fwrite_fread()
90
90
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
91
91
TEST_ASSERT_EQUAL_INT (str1_size, write_ret);
92
92
93
- #ifndef __ICCARM__ // prevents IAR infinite loop
94
93
// write 3; expected written 2
95
94
TestFile<FS>::resetFunctionCallHistory ();
96
95
write_ret = std::fwrite (str2, 1 , str2_size, file);
97
96
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
98
97
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
99
- std::clearerr (file); // for ARMCC
100
- #ifndef __ARMCC_VERSION
101
- // ARMCC returns 0 here instead of number of elements successfully written
102
- TEST_ASSERT_EQUAL_INT (str2_size - 1 , write_ret);
103
- #endif
98
+ std::clearerr (file);
99
+
100
+ // ARMCC/IAR returns 0 here instead of number of elements successfully written !!!
101
+ TEST_ASSERT_TRUE (write_ret >= 0 && write_ret <= (str2_size - 1 ));
104
102
105
103
// write 3; expected written 0
106
104
TestFile<FS>::resetFunctionCallHistory ();
107
105
write_ret = std::fwrite (str1, 1 , str1_size, file);
108
106
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
109
107
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
110
108
TEST_ASSERT_EQUAL_INT (0 , write_ret);
111
- #endif
112
109
113
110
std::rewind (file);
114
111
@@ -119,13 +116,12 @@ void test_fwrite_fread()
119
116
TEST_ASSERT_EQUAL_INT (str1_size, read_ret);
120
117
TEST_ASSERT_EQUAL_INT (0 , strncmp (str1, read_buf, str1_size));
121
118
122
- #ifndef __ICCARM__
123
119
// read 3; expected read 2
124
120
TestFile<FS>::resetFunctionCallHistory ();
125
121
read_ret = std::fread (read_buf, 1 , str2_size, file);
126
122
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
127
123
TEST_ASSERT_TRUE (std::feof (file) != 0 );
128
- std::clearerr (file); // for ARMCC
124
+ std::clearerr (file);
129
125
TEST_ASSERT_EQUAL_INT (str2_size - 1 , read_ret);
130
126
TEST_ASSERT_EQUAL_INT (0 , strncmp (str2, read_buf, str2_size - 1 ));
131
127
@@ -135,11 +131,12 @@ void test_fwrite_fread()
135
131
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
136
132
TEST_ASSERT_TRUE (std::feof (file) != 0 );
137
133
TEST_ASSERT_EQUAL_INT (0 , read_ret);
138
- #endif
139
134
140
135
std::fclose (file);
141
136
}
142
137
138
+
139
+
143
140
/* * Test fputc and fgetc
144
141
*
145
142
* Given already opened file
@@ -168,7 +165,6 @@ void test_fputc_fgetc()
168
165
TEST_ASSERT_NOT_NULL (file);
169
166
std::setbuf (file, NULL );
170
167
171
-
172
168
// write 1; expected written 1
173
169
TestFile<FS>::resetFunctionCallHistory ();
174
170
ret = std::fputc (char_buf[0 ], file);
@@ -187,14 +183,12 @@ void test_fputc_fgetc()
187
183
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
188
184
TEST_ASSERT_EQUAL_INT (char_buf[2 ], ret);
189
185
190
- #ifndef __ICCARM__ // prevents IAR infinite loop
191
186
// write 1; expected written 0
192
187
TestFile<FS>::resetFunctionCallHistory ();
193
188
ret = std::fputc (char_buf[0 ], file);
194
189
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
195
190
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
196
191
TEST_ASSERT_EQUAL_INT (EOF, ret);
197
- #endif
198
192
199
193
std::rewind (file);
200
194
@@ -207,29 +201,19 @@ void test_fputc_fgetc()
207
201
// read 1; expected read 1
208
202
TestFile<FS>::resetFunctionCallHistory ();
209
203
ret = std::fgetc (file);
210
- #ifndef __ICCARM__
211
- // IAR optimize reads
212
- TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
213
- #endif
214
204
TEST_ASSERT_EQUAL_INT (char_buf[1 ], ret);
215
205
216
206
// read 1; expected read 1
217
207
TestFile<FS>::resetFunctionCallHistory ();
218
208
ret = std::fgetc (file);
219
- #ifndef __ICCARM__
220
- // IAR optimize reads
221
- TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
222
- #endif
223
209
TEST_ASSERT_EQUAL_INT (char_buf[2 ], ret);
224
210
225
- #ifndef __ICCARM__
226
211
// read 1; expected read 0
227
212
TestFile<FS>::resetFunctionCallHistory ();
228
213
ret = std::fgetc (file);
229
214
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
230
215
TEST_ASSERT_TRUE (std::feof (file) != 0 );
231
216
TEST_ASSERT_EQUAL_INT (EOF, ret);
232
- #endif
233
217
234
218
std::fclose (file);
235
219
}
@@ -273,13 +257,12 @@ void test_fputs_fgets()
273
257
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
274
258
TEST_ASSERT_TRUE (fputs_ret >= 0 );
275
259
276
- #ifndef __ICCARM__ // prevents IAR infinite loop
277
260
// write 3; expected written 2
278
261
TestFile<FS>::resetFunctionCallHistory ();
279
262
fputs_ret = std::fputs (str2, file);
280
263
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
281
264
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
282
- std::clearerr (file); // for ARMCC
265
+ std::clearerr (file);
283
266
TEST_ASSERT_EQUAL_INT (EOF, fputs_ret);
284
267
285
268
// write 3; expected written 0
@@ -288,7 +271,6 @@ void test_fputs_fgets()
288
271
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
289
272
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
290
273
TEST_ASSERT_EQUAL_INT (EOF, fputs_ret);
291
- #endif
292
274
293
275
std::rewind (file);
294
276
@@ -299,13 +281,12 @@ void test_fputs_fgets()
299
281
TEST_ASSERT_EQUAL_INT (read_buf, fgets_ret);
300
282
TEST_ASSERT_EQUAL_INT (0 , strncmp (read_buf, str1, str1_size));
301
283
302
- #ifndef __ICCARM__
303
284
// read 3; expected read 2
304
285
TestFile<FS>::resetFunctionCallHistory ();
305
286
fgets_ret = std::fgets (read_buf, str2_size + 1 , file);
306
287
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
307
288
TEST_ASSERT_TRUE (std::feof (file) != 0 );
308
- std::clearerr (file); // for ARMCC
289
+ std::clearerr (file);
309
290
TEST_ASSERT_EQUAL_INT (read_buf, fgets_ret);
310
291
TEST_ASSERT_EQUAL_INT (0 , strncmp (read_buf, str2, str2_size - 2 ));
311
292
@@ -315,7 +296,6 @@ void test_fputs_fgets()
315
296
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
316
297
TEST_ASSERT_TRUE (std::feof (file) != 0 );
317
298
TEST_ASSERT_EQUAL_INT (NULL , fgets_ret);
318
- #endif
319
299
320
300
std::fclose (file);
321
301
}
@@ -359,13 +339,12 @@ void test_fprintf_fscanf()
359
339
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
360
340
TEST_ASSERT_EQUAL_INT (str1_size, fprintf_ret);
361
341
362
- #ifndef __ICCARM__ // prevents IAR infinite loop
363
342
// write 3; expected written 2
364
343
TestFile<FS>::resetFunctionCallHistory ();
365
344
fprintf_ret = fprintf (file, " %s" , str2);
366
345
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
367
346
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
368
- std::clearerr (file); // for ARMCC
347
+ std::clearerr (file);
369
348
TEST_ASSERT_TRUE (fprintf_ret < 0 );
370
349
371
350
// write 3; expected written 0
@@ -374,7 +353,6 @@ void test_fprintf_fscanf()
374
353
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnWrite));
375
354
TEST_ASSERT_TRUE (std::ferror (file) != 0 );
376
355
TEST_ASSERT_TRUE (fprintf_ret < 0 );
377
- #endif
378
356
379
357
std::rewind (file);
380
358
@@ -385,13 +363,12 @@ void test_fprintf_fscanf()
385
363
TEST_ASSERT_EQUAL_INT (1 , fscanf_ret);
386
364
TEST_ASSERT_EQUAL_INT (0 , strncmp (read_buf, str1, str1_size));
387
365
388
- #ifndef __ICCARM__
389
366
// read 3; expected read 2
390
367
TestFile<FS>::resetFunctionCallHistory ();
391
368
fscanf_ret = fscanf (file, " %3s" , read_buf);
392
369
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
393
370
TEST_ASSERT_TRUE (std::feof (file) != 0 );
394
- std::clearerr (file); // for ARMCC
371
+ std::clearerr (file);
395
372
TEST_ASSERT_EQUAL_INT (1 , fscanf_ret);
396
373
TEST_ASSERT_EQUAL_INT (0 , strncmp (read_buf, str2, str2_size - 1 ));
397
374
@@ -401,7 +378,6 @@ void test_fprintf_fscanf()
401
378
TEST_ASSERT_TRUE (TestFile<FS>::functionCalled (TestFile<FS>::fnRead));
402
379
TEST_ASSERT_TRUE (std::feof (file) != 0 );
403
380
TEST_ASSERT_EQUAL_INT (EOF, fscanf_ret);
404
- #endif
405
381
406
382
std::fclose (file);
407
383
}
0 commit comments