sprintf_tc.c 555 B

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