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

Function test_destinationSpecificPaths

tests/unit/test_all_paths.c:271–304  ·  view source on GitHub ↗

Test all paths from source to a specific destination node.

Source from the content-addressed store, hash-verified

269
270// Test all paths from source to a specific destination node.
271void test_destinationSpecificPaths() {
272 NodeID p00_0[2] = {1, 0};
273 NodeID p00_1[4] = {3, 0, 1, 0};
274 NodeID p00_2[6] = {5, 0, 1, 2, 1, 0};
275 NodeID p00_4[6] = {5, 0, 1, 2, 3, 0};
276 NodeID p00_3[5] = {4, 0, 2, 1, 0};
277 NodeID p00_5[5] = {4, 0, 2, 3, 0};
278
279 NodeID *p00[6] = {p00_0, p00_1, p00_2, p00_3, p00_4, p00_5};
280
281 Graph *g = BuildGraph();
282
283 NodeID src_id = 0;
284 Node src;
285 Path *path = NULL;
286 Graph_GetNode(g, src_id, &src);
287 unsigned int minLen = 0;
288 unsigned int maxLen = UINT_MAX - 2;
289 unsigned int pathsCount = 0;
290 int relationships[] = {GRAPH_NO_RELATION};
291 AllPathsCtx *ctx = AllPathsCtx_New(&src, &src, g, relationships, 1,
292 GRAPH_EDGE_DIR_OUTGOING, minLen, maxLen, NULL, NULL, 0, false);
293
294 while((path = AllPathsCtx_NextPath(ctx))) {
295 TEST_ASSERT(pathsCount < 5);
296 TEST_ASSERT(pathArrayContainsPath(p00, 6, path));
297 pathsCount++;
298 }
299
300 TEST_ASSERT(pathsCount == 5);
301
302 AllPathsCtx_Free(ctx);
303 Graph_Free(g);
304}
305
306TEST_LIST = {
307 {"noPaths", test_noPaths},

Callers

nothing calls this directly

Calls 7

Graph_GetNodeFunction · 0.85
AllPathsCtx_NewFunction · 0.85
AllPathsCtx_NextPathFunction · 0.85
pathArrayContainsPathFunction · 0.85
AllPathsCtx_FreeFunction · 0.85
Graph_FreeFunction · 0.85
BuildGraphFunction · 0.70

Tested by

no test coverage detected