fclose_tc.c 599 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <stdio.h>
  2. static int fclose_entry(void)
  3. {
  4. FILE *stream;
  5. stream = fopen("fopen_file.txt","a+");
  6. if (stream == NULL)
  7. {
  8. perror("fopen fail");
  9. return -1;
  10. }
  11. if(fclose(stream) != 0)
  12. {
  13. perror("fclose fail");
  14. return -1;
  15. }
  16. else
  17. {
  18. printf("fclose success \n");
  19. }
  20. return 0;
  21. }
  22. #include <utest.h>
  23. static void test_fclose(void)
  24. {
  25. uassert_int_equal(fclose_entry(), 0);
  26. }
  27. static void testcase(void)
  28. {
  29. UTEST_UNIT_RUN(test_fclose);
  30. }
  31. UTEST_TC_EXPORT(testcase, "posix.stdio_h.fclose.c", RT_NULL, RT_NULL, 10);