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

Function test_match

tests/unit/test_referenced_entities.c:38–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void test_match() {
39 // test for no inline filters
40 char *q = "MATCH (n)";
41 AST *ast = buildAST(q);
42 uint *segmentIndices = getASTSegmentIndices(ast);
43 TEST_ASSERT(1 == array_len(segmentIndices));
44
45 AST *astSegment = AST_NewSegment(ast, 0, segmentIndices[0]);
46 TEST_ASSERT(0 == raxSize(astSegment->referenced_entities));
47 array_free(segmentIndices);
48 AST_Free(astSegment);
49 AST_Free(ast);
50
51 q = "MATCH (n)-[e]->(m)";
52 ast = buildAST(q);
53 segmentIndices = getASTSegmentIndices(ast);
54 TEST_ASSERT(1 == array_len(segmentIndices));
55 astSegment = AST_NewSegment(ast, 0, segmentIndices[0]);
56 TEST_ASSERT(0 == raxSize(astSegment->referenced_entities));
57 array_free(segmentIndices);
58 AST_Free(astSegment);
59 AST_Free(ast);
60
61 // Inline node label filter.
62 q = "MATCH (n:X)-[e]->(m)";
63 ast = buildAST(q);
64 segmentIndices = getASTSegmentIndices(ast);
65 TEST_ASSERT(1 == array_len(segmentIndices));
66 astSegment = AST_NewSegment(ast, 0, segmentIndices[0]);
67 TEST_ASSERT(0 == raxSize(astSegment->referenced_entities));
68 TEST_ASSERT(raxNotFound == raxFind(astSegment->referenced_entities, (unsigned char *)"n", 1));
69 TEST_ASSERT(raxNotFound == raxFind(astSegment->referenced_entities, (unsigned char *)"e", 1));
70 TEST_ASSERT(raxNotFound == raxFind(astSegment->referenced_entities, (unsigned char *)"m", 1));
71 array_free(segmentIndices);
72 AST_Free(astSegment);
73 AST_Free(ast);
74
75 // Inline node property filter.
76 q = "MATCH (n {val:42})-[e]->(m)";
77 ast = buildAST(q);
78 segmentIndices = getASTSegmentIndices(ast);
79 TEST_ASSERT(1 == array_len(segmentIndices));
80 astSegment = AST_NewSegment(ast, 0, segmentIndices[0]);
81 TEST_ASSERT(1 == raxSize(astSegment->referenced_entities));
82 TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"n", 1));
83 TEST_ASSERT(raxNotFound == raxFind(astSegment->referenced_entities, (unsigned char *)"e", 1));
84 TEST_ASSERT(raxNotFound == raxFind(astSegment->referenced_entities, (unsigned char *)"m", 1));
85 array_free(segmentIndices);
86 AST_Free(astSegment);
87 AST_Free(ast);
88
89 // Inline edge relationship type.
90 q = "MATCH (n)-[e:T]->(m)";
91 ast = buildAST(q);
92 segmentIndices = getASTSegmentIndices(ast);
93 TEST_ASSERT(1 == array_len(segmentIndices));
94 astSegment = AST_NewSegment(ast, 0, segmentIndices[0]);
95 TEST_ASSERT(0 == raxSize(astSegment->referenced_entities));

Callers

nothing calls this directly

Calls 6

buildASTFunction · 0.85
getASTSegmentIndicesFunction · 0.85
array_lenFunction · 0.85
AST_NewSegmentFunction · 0.85
array_freeFunction · 0.85
AST_FreeFunction · 0.85

Tested by

no test coverage detected