| 12 | } |
| 13 | |
| 14 | static void test_file(void) |
| 15 | { |
| 16 | const char *filename = "test2.txt"; |
| 17 | ACL_FILE *fp = acl_fopen(filename, "a+"); |
| 18 | char buf[1024]; |
| 19 | int i; |
| 20 | |
| 21 | if (fp == NULL) { |
| 22 | printf("fopen %s error(%s)\n", filename, acl_last_serror()); |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | for (i = 0 ; i < 100; i++) { |
| 27 | if (acl_fputs("hello world!", fp) == EOF) { |
| 28 | printf("fputs to %s error(%s)\n", filename, acl_last_serror()); |
| 29 | break; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | printf("write to %s ok\n", filename); |
| 34 | acl_fclose(fp); |
| 35 | |
| 36 | fp = acl_fopen(filename, "r"); |
| 37 | if (fp == NULL) { |
| 38 | printf("fopen %s error(%s)\n", filename, acl_last_serror()); |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | i = 0; |
| 43 | while (!acl_feof(fp)) { |
| 44 | if (acl_fgets(buf, sizeof(buf), fp) == NULL) { |
| 45 | printf("fgets return null, i=%d\n", i); |
| 46 | } else { |
| 47 | i++; |
| 48 | printf(">>gets line(%d): %s", i, buf); |
| 49 | } |
| 50 | } |
| 51 | acl_fclose(fp); |
| 52 | } |
| 53 | |
| 54 | static int test_file3(void) |
| 55 | { |
no test coverage detected
searching dependent graphs…