1
0

ftell_tc.c 685 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <stdio.h>
  2. #include <string.h>
  3. static int ftell_entry(void)
  4. {
  5. FILE *stream;
  6. char str[] = "123456789";
  7. int ret = 0;
  8. stream = fopen("fopen_file.txt","w");
  9. if (stream == NULL)
  10. {
  11. perror("fopen");
  12. ret = -1;
  13. }
  14. else
  15. {
  16. fprintf(stream, "%s",str);
  17. if(ftell(stream) != strlen(str))
  18. {
  19. ret = -1;
  20. }
  21. fclose(stream);
  22. }
  23. return ret;
  24. }
  25. #include <utest.h>
  26. static void test_ftell(void)
  27. {
  28. uassert_int_equal(ftell_entry(), 0);
  29. }
  30. static void testcase(void)
  31. {
  32. UTEST_UNIT_RUN(test_ftell);
  33. }
  34. UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);