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

Function test_namePath

tests/unit/test_referenced_entities.c:458–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

456}
457
458void test_namePath() {
459 char *q = "MATCH p=()";
460 AST *ast = buildAST(q);
461 uint *segmentIndices = getASTSegmentIndices(ast);
462 TEST_ASSERT(1 == array_len(segmentIndices));
463
464 AST *astSegment = AST_NewSegment(ast, 0, segmentIndices[0]);
465 TEST_ASSERT(1 == raxSize(astSegment->referenced_entities));
466 TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"@anon_0", 7));
467 array_free(segmentIndices);
468 AST_Free(astSegment);
469 AST_Free(ast);
470
471 q = "MATCH p =()-[]-()";
472 ast = buildAST(q);
473 segmentIndices = getASTSegmentIndices(ast);
474 TEST_ASSERT(1 == array_len(segmentIndices));
475
476 astSegment = AST_NewSegment(ast, 0, segmentIndices[0]);
477 TEST_ASSERT(3 == raxSize(astSegment->referenced_entities));
478 TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"@anon_0", 7));
479 TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"@anon_1", 7));
480 TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"@anon_2", 7));
481 array_free(segmentIndices);
482 AST_Free(astSegment);
483 AST_Free(ast);
484
485 q = "MATCH p =(n)-[e]-(m)";
486 ast = buildAST(q);
487 segmentIndices = getASTSegmentIndices(ast);
488 TEST_ASSERT(1 == array_len(segmentIndices));
489
490 astSegment = AST_NewSegment(ast, 0, segmentIndices[0]);
491 TEST_ASSERT(3 == raxSize(astSegment->referenced_entities));
492 TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"n", 1));
493 TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"e", 1));
494 TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"m", 1));
495 array_free(segmentIndices);
496 AST_Free(astSegment);
497 AST_Free(ast);
498
499 q = "MATCH p =(:Label1 {value:1})-[e:Rel*]-(m:Label2 {value:2})";
500 ast = buildAST(q);
501 segmentIndices = getASTSegmentIndices(ast);
502 TEST_ASSERT(1 == array_len(segmentIndices));
503
504 astSegment = AST_NewSegment(ast, 0, segmentIndices[0]);
505 TEST_ASSERT(3 == raxSize(astSegment->referenced_entities));
506 TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"@anon_0", 7));
507 TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"e", 1));
508 TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"m", 1));
509 array_free(segmentIndices);
510 AST_Free(astSegment);
511 AST_Free(ast);
512}
513
514TEST_LIST = {
515 {"match", test_match},

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