1 #include <stdio.h>
2 
fputc_entry(void)3 static int fputc_entry(void)
4 {
5     FILE *stream;
6     int ch = 'a';
7     int getc = {0};
8     size_t size = 0;
9     int ret = 0;
10 
11     stream = fopen("fopen_file.txt","w");
12     if (stream == NULL)
13     {
14         perror("fopen fail");
15         ret = -1;
16         goto __exit;
17     }
18     fputc(ch, stream);
19     fclose(stream);
20 
21     stream = fopen("fopen_file.txt","r");
22     getc = fgetc(stream);
23 
24     if(getc != ch)
25     {
26         perror("fputc");
27         ret = -1;
28     }
29 __exit:
30     fclose(stream);
31     return ret;
32 }
33 
34 #include <utest.h>
test_fputc(void)35 static void test_fputc(void)
36 {
37     uassert_int_equal(fputc_entry(), 0);
38 }
testcase(void)39 static void testcase(void)
40 {
41     UTEST_UNIT_RUN(test_fputc);
42 }
43 UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
44 
45