MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test_DFSLevels

Function test_DFSLevels

tests/unit/test_dfs.c:59–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59void test_DFSLevels() {
60 QGNode *S; // DFS starts here.
61 QGEdge **path; // Path reached by DFS.
62 QueryGraph *g; // Graph traversed.
63
64 g = BuildGraph();
65 S = QueryGraph_GetNodeByAlias(g, "A");
66
67 QGEdge *expected_level_0[0] = {};
68 QGEdge *expected_level_1[1] = {AB};
69 QGEdge *expected_level_2[2] = {AB, BC};
70 QGEdge *expected_level_3[3] = {AB, BC, CD};
71 QGEdge *expected_level_4[0] = {};
72
73 QGEdge **expected[5] = {
74 expected_level_0,
75 expected_level_1,
76 expected_level_2,
77 expected_level_3,
78 expected_level_4
79 };
80
81 //------------------------------------------------------------------------------
82 // DFS depth 0 - 4
83 //------------------------------------------------------------------------------
84
85 for(int level = 0; level < 5; level++) {
86 path = DFS(S, level, true);
87 QGEdge **expectation = expected[level];
88
89 int edge_count = array_len(path);
90 for(int i = 0; i < edge_count; i++) {
91 bool found = false;
92 for(int j = 0; j < edge_count; j++) {
93 if(path[i] == expectation[j]) {
94 found = true;
95 break;
96 }
97 }
98 TEST_ASSERT(found);
99 }
100 array_free(path);
101 }
102
103 // Clean up.
104 QueryGraph_Free(g);
105}
106
107TEST_LIST = {
108 {"DFSLevels", test_DFSLevels},

Callers

nothing calls this directly

Calls 6

DFSFunction · 0.85
array_lenFunction · 0.85
array_freeFunction · 0.85
QueryGraph_FreeFunction · 0.85
BuildGraphFunction · 0.70

Tested by

no test coverage detected