1 #include <stdio.h>
2 #include <string.h>
3 
fdopen_entry(void)4 static int fdopen_entry(void)
5 {
6     long l;
7     char s[81] = {0};
8     char c;
9     int ret = 0;
10     FILE* stream = fopen("fopen_file.txt","w+");
11     if(stream == NULL)
12     {
13         ret = -1;
14         perror("fopen");
15     }
16     else
17     {
18         fprintf(stream,"%s %d %c","a_string",6500,'x');
19         fseek(stream,0L,SEEK_SET);
20         fscanf(stream,"%s",s);
21         fscanf(stream,"%ld",&l);
22         fscanf(stream," %c",&c);
23 
24         if((strcmp(s,"a_string") != 0) || (l != 6500) || (c != 'x'))
25         {
26             ret = -1;
27         }
28 
29         fclose(stream);
30     }
31     return ret;
32 }
33 
34 #include <utest.h>
test_fdopen(void)35 static void test_fdopen(void)
36 {
37     uassert_int_equal(fdopen_entry(), 0);
38 }
testcase(void)39 static void testcase(void)
40 {
41     UTEST_UNIT_RUN(test_fdopen);
42 }
43 UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
44 
45