1 #include <stdio.h>
2 #include <stdarg.h>
3 #include <string.h>
4
5 static char buf[64] = {0};
WriteFrmtd(char * format,...)6 static void WriteFrmtd(char *format, ...)
7 {
8 va_list args;
9
10 va_start(args, format);
11 vsprintf(buf, format, args);
12 va_end(args);
13 }
14
vsprintf_entry(void)15 static int vsprintf_entry(void)
16 {
17 char buf[64] = {0};
18 char test_data[] = "vsprintf test:2021-8-1 3.14 0xff";
19 sprintf(buf, "vsprintf test:%s-%d-%c %.02f 0x%x","2021" ,8 ,'1' ,3.14 ,0xff);
20
21 if(strcmp(buf, test_data))
22 {
23 return -1;
24 }
25 return 0;
26 }
27
28 #include <utest.h>
test_vsprintf(void)29 static void test_vsprintf(void)
30 {
31 uassert_int_equal(vsprintf_entry(), 0);
32 }
testcase(void)33 static void testcase(void)
34 {
35 UTEST_UNIT_RUN(test_vsprintf);
36 }
37 UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);
38
39