1 #include <stdio.h>
2 #include <string.h>
3 
sprintf_entry(void)4 static int sprintf_entry(void)
5 {
6     char buf[64] = {0};
7     char test_data[] = "sprintf test:2021-8-1 3.14 0xff";
8     sprintf(buf, "sprintf test:%s-%d-%c %.02f 0x%x","2021" ,8 ,'1' ,3.14 ,0xff);
9 
10     if(strcmp(buf, test_data))
11     {
12         return -1;
13     }
14     return 0;
15 }
16 
17 #include <utest.h>
test_sprintf(void)18 static void test_sprintf(void)
19 {
20     uassert_int_equal(sprintf_entry(), 0);
21 }
testcase(void)22 static void testcase(void)
23 {
24     UTEST_UNIT_RUN(test_sprintf);
25 }
26 UTEST_TC_EXPORT(testcase, "posix.stdio_h.sprintf.c", RT_NULL, RT_NULL, 10);
27 
28