Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | #include "Graph.h" | ||
8 | |||
9 | ///Test the graph iteration | ||
10 | /** @param graph : Graph on which to iterate | ||
11 | * @return true on success, false otherwise | ||
12 | */ | ||
13 | 1 | bool testIterateGraph(const Graph<bool, long> & graph){ | |
14 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
|
1 | std::cout << "testIterateGraph : iterateParent :" << std::endl; |
15 | 1 | std::list<long> listNodeToParent; | |
16 |
3/3✓ Branch 0 (18→19) taken 4 times.
✓ Branch 2 (19→6) taken 3 times.
✓ Branch 3 (19→20) taken 1 times.
|
4 | while(graph.iterateParent(listNodeToParent)){ |
17 |
2/2✓ Branch 0 (6→7) taken 3 times.
✓ Branch 2 (7→8) taken 3 times.
|
3 | std::cout << "To parent iteration :" << std::endl; |
18 |
2/2✓ Branch 0 (16→9) taken 5 times.
✓ Branch 1 (16→17) taken 3 times.
|
8 | for(std::list<long>::iterator it(listNodeToParent.begin()); it != listNodeToParent.end(); ++it){ |
19 |
3/3✓ Branch 0 (9→10) taken 5 times.
✓ Branch 2 (11→12) taken 5 times.
✓ Branch 4 (12→13) taken 5 times.
|
5 | std::cout << "\t" << (*it) << std::endl; |
20 | } | ||
21 | } | ||
22 |
2/2✓ Branch 0 (20→21) taken 1 times.
✓ Branch 2 (21→22) taken 1 times.
|
1 | std::cout << "testIterateGraph : iterateChildren :" << std::endl; |
23 | 1 | std::list<long> listNodeToChldren; | |
24 |
3/3✓ Branch 0 (36→37) taken 4 times.
✓ Branch 2 (37→24) taken 3 times.
✓ Branch 3 (37→38) taken 1 times.
|
4 | while(graph.iterateChildren(listNodeToChldren)){ |
25 |
2/2✓ Branch 0 (24→25) taken 3 times.
✓ Branch 2 (25→26) taken 3 times.
|
3 | std::cout << "To children iteration :" << std::endl; |
26 |
2/2✓ Branch 0 (34→27) taken 6 times.
✓ Branch 1 (34→35) taken 3 times.
|
9 | for(std::list<long>::iterator it(listNodeToChldren.begin()); it != listNodeToChldren.end(); ++it){ |
27 |
3/3✓ Branch 0 (27→28) taken 6 times.
✓ Branch 2 (29→30) taken 6 times.
✓ Branch 4 (30→31) taken 6 times.
|
6 | std::cout << "\t" << (*it) << std::endl; |
28 | } | ||
29 | } | ||
30 | 1 | return true; | |
31 | 1 | } | |
32 | |||
33 | ///Test the graph iteration | ||
34 | /** @param graph : Graph on which to iterate | ||
35 | * @return true on success, false otherwise | ||
36 | */ | ||
37 | 1 | bool testIterateGraphUnique(Graph<bool, long> & graph){ | |
38 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 2 (3→4) taken 1 times.
|
1 | std::cout << "testIterateGraphUnique : iterateParentCheckUpdate :" << std::endl; |
39 | 1 | std::list<long> listNodeToParent; | |
40 |
3/3✓ Branch 0 (18→19) taken 4 times.
✓ Branch 2 (19→6) taken 3 times.
✓ Branch 3 (19→20) taken 1 times.
|
4 | while(graph.iterateParentCheckUpdate(listNodeToParent)){ |
41 |
2/2✓ Branch 0 (6→7) taken 3 times.
✓ Branch 2 (7→8) taken 3 times.
|
3 | std::cout << "To parent iteration :" << std::endl; |
42 |
2/2✓ Branch 0 (16→9) taken 5 times.
✓ Branch 1 (16→17) taken 3 times.
|
8 | for(std::list<long>::iterator it(listNodeToParent.begin()); it != listNodeToParent.end(); ++it){ |
43 |
3/3✓ Branch 0 (9→10) taken 5 times.
✓ Branch 2 (11→12) taken 5 times.
✓ Branch 4 (12→13) taken 5 times.
|
5 | std::cout << "\t" << (*it) << std::endl; |
44 | } | ||
45 | } | ||
46 | |||
47 |
2/2✓ Branch 0 (20→21) taken 1 times.
✓ Branch 2 (21→22) taken 1 times.
|
1 | std::cout << "testIterateGraphUnique : iterateChildrenCheckUpdate :" << std::endl; |
48 | 1 | std::list<long> listNodeToChldren; | |
49 |
3/3✓ Branch 0 (36→37) taken 3 times.
✓ Branch 2 (37→24) taken 2 times.
✓ Branch 3 (37→38) taken 1 times.
|
3 | while(graph.iterateChildrenCheckUpdate(listNodeToChldren)){ |
50 |
2/2✓ Branch 0 (24→25) taken 2 times.
✓ Branch 2 (25→26) taken 2 times.
|
2 | std::cout << "To children iteration :" << std::endl; |
51 |
2/2✓ Branch 0 (34→27) taken 5 times.
✓ Branch 1 (34→35) taken 2 times.
|
7 | for(std::list<long>::iterator it(listNodeToChldren.begin()); it != listNodeToChldren.end(); ++it){ |
52 |
3/3✓ Branch 0 (27→28) taken 5 times.
✓ Branch 2 (29→30) taken 5 times.
✓ Branch 4 (30→31) taken 5 times.
|
5 | std::cout << "\t" << (*it) << std::endl; |
53 | } | ||
54 | } | ||
55 | 1 | return true; | |
56 | 1 | } | |
57 | |||
58 | ///Test the graph conversion to dot | ||
59 | /** @return true on success, false otherwise | ||
60 | */ | ||
61 | 1 | bool testGraphToDot(){ | |
62 |
1/1✓ Branch 0 (2→3) taken 1 times.
|
1 | Graph<bool, long> graph; |
63 | |||
64 |
2/2✓ Branch 0 (5→6) taken 1 times.
✓ Branch 2 (6→7) taken 1 times.
|
2 | long nodeA = graph.createNode(true, "0"); |
65 |
2/2✓ Branch 0 (11→12) taken 1 times.
✓ Branch 2 (12→13) taken 1 times.
|
2 | long nodeB = graph.createNode(true, "1"); |
66 |
2/2✓ Branch 0 (17→18) taken 1 times.
✓ Branch 2 (18→19) taken 1 times.
|
2 | long nodeC = graph.createNode(true, "2"); |
67 |
2/2✓ Branch 0 (23→24) taken 1 times.
✓ Branch 2 (24→25) taken 1 times.
|
2 | long nodeD = graph.createNode(true, "3"); |
68 |
2/2✓ Branch 0 (29→30) taken 1 times.
✓ Branch 2 (30→31) taken 1 times.
|
1 | long nodeE = graph.createNode(true, "4"); |
69 | |||
70 |
1/1✓ Branch 0 (33→34) taken 1 times.
|
1 | graph.connectNode(nodeA, nodeC); |
71 |
1/1✓ Branch 0 (34→35) taken 1 times.
|
1 | graph.connectNode(nodeB, nodeC); |
72 |
1/1✓ Branch 0 (35→36) taken 1 times.
|
1 | graph.connectNode(nodeC, nodeE); |
73 |
1/1✓ Branch 0 (36→37) taken 1 times.
|
1 | graph.connectNode(nodeD, nodeE); |
74 | |||
75 | 1 | bool b(true); | |
76 |
2/2✓ Branch 0 (39→40) taken 1 times.
✓ Branch 2 (40→41) taken 1 times.
|
2 | b &= graph.savePng("testGraph.png"); |
77 |
2/2✓ Branch 0 (45→46) taken 1 times.
✓ Branch 2 (46→47) taken 1 times.
|
2 | b &= !graph.saveDot(""); |
78 |
2/2✓ Branch 0 (51→52) taken 1 times.
✓ Branch 2 (52→53) taken 1 times.
|
2 | b &= !graph.savePng(""); |
79 |
2/2✓ Branch 0 (57→58) taken 1 times.
✓ Branch 2 (58→59) taken 1 times.
|
2 | b &= !graph.saveDot("someInexistingDir/someFile.dot"); |
80 |
2/2✓ Branch 0 (63→64) taken 1 times.
✓ Branch 2 (64→65) taken 1 times.
|
1 | b &= !graph.savePng("someInexistingDir/someFile.png"); |
81 | |||
82 | 1 | b &= graph.size() == 5lu; | |
83 | |||
84 |
1/1✓ Branch 0 (68→69) taken 1 times.
|
1 | graph.updateFirstLastNode(); |
85 |
1/1✓ Branch 0 (69→70) taken 1 times.
|
1 | b &= testIterateGraph(graph); |
86 |
1/1✓ Branch 0 (70→71) taken 1 times.
|
1 | b &= testIterateGraphUnique(graph); |
87 | |||
88 |
3/3✓ Branch 0 (71→72) taken 1 times.
✓ Branch 2 (72→73) taken 1 times.
✓ Branch 4 (73→74) taken 1 times.
|
1 | std::cout << "testGraphToDot : b = " << b << std::endl; |
89 | 1 | return b; | |
90 | 1 | } | |
91 | |||
92 | |||
93 | 1 | int main(int argc, char** argv){ | |
94 | 1 | bool b(testGraphToDot()); | |
95 | 1 | std::cout << "b = " << b << std::endl; | |
96 | 1 | return b - 1; | |
97 | } | ||
98 | |||
99 | |||
100 |