Debian Codegraph @

tests/2705.c

raw
1 /// @file
2 /// @brief supporting application for test_regression.py::test_2705
3
4 #include <assert.h>
5 #include <graphviz/cgraph.h>
6 #include <stddef.h>
7 #include <stdio.h>
8
9 int main(int argc, char **argv) {
10
11 assert(argc == 3);
12 (void)argc;
13
14 // create a graph with an unlabeled node
15 Agraph_t *const g1 = agopen(NULL, Agdirected, NULL);
16 assert(g1 != NULL);
17 Agnode_t *const n = agnode(g1, "1", 1);
18 assert(n != NULL);
19 (void)n;
20
21 // write it to a file
22 FILE *const out1 = fopen(argv[1], "w+");
23 assert(out1 != NULL);
24 {
25 const int rc = agwrite(g1, out1);
26 assert(rc == 0);
27 (void)rc;
28 }
29 (void)fflush(out1);
30
31 (void)agclose(g1);
32
33 // parse this back in
34 rewind(out1);
35 Agraph_t *const g2 = agread(out1, NULL);
36 assert(g2 != NULL);
37 (void)fclose(out1);
38
39 // write this one into a separate file
40 FILE *const out2 = fopen(argv[2], "w");
41 assert(out2 != NULL);
42 {
43 const int rc = agwrite(g2, out2);
44 assert(rc == 0);
45 (void)rc;
46 }
47
48 agclose(g2);
49 (void)fclose(out2);
50
51 return 0;
52 }