MCPcopy Create free account
hub / github.com/acl-dev/acl / test_file

Function test_file

lib_acl/samples/file/main.cpp:14–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12}
13
14static 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
54static int test_file3(void)
55{

Callers 1

mainFunction · 0.70

Calls 6

acl_fopenFunction · 0.85
acl_last_serrorFunction · 0.85
acl_fputsFunction · 0.85
acl_fcloseFunction · 0.85
acl_feofFunction · 0.85
acl_fgetsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…