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

Function test_VariableLength

tests/unit/test_algebraic_expression.c:1463–1500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1461}
1462
1463void test_VariableLength() {
1464 const char *q =
1465 "MATCH (p:Person)-[ef:friend]->(f:Person)-[:visit*1..3]->(c:City)-[ew:war]->(e:City) RETURN p,e";
1466 AST *master_ast;
1467 AlgebraicExpression **actual = build_algebraic_expression(q, &master_ast);
1468 uint exp_count = array_len(actual);
1469 TEST_ASSERT(exp_count == 3);
1470
1471 AlgebraicExpression *expected[3];
1472 expected[0] = AlgebraicExpression_FromString("p*F*f", _matrices);
1473 expected[1] = AlgebraicExpression_FromString("V", _matrices);
1474 expected[2] = AlgebraicExpression_FromString("c*W*e", _matrices);
1475 compare_algebraic_expressions(actual, expected, 3);
1476
1477 // Clean up.
1478 free_algebraic_expressions(actual, exp_count);
1479 free_algebraic_expressions(expected, exp_count);
1480 array_free(actual);
1481 AST_Free(master_ast);
1482
1483 // Transposed variable length.
1484 exp_count = 0;
1485 q = "MATCH (p:Person)-[ef:friend]->(f:Person)<-[:visit*1..3]-(c:City)-[ew:war]->(e:City) RETURN p,e";
1486 actual = build_algebraic_expression(q, &master_ast);
1487 exp_count = array_len(actual);
1488 TEST_ASSERT(exp_count == 3);
1489
1490 expected[0] = AlgebraicExpression_FromString("p*F*f", _matrices);
1491 expected[1] = AlgebraicExpression_FromString("tV", _matrices);
1492 expected[2] = AlgebraicExpression_FromString("c*W*e", _matrices);
1493 compare_algebraic_expressions(actual, expected, 3);
1494
1495 // Clean up.
1496 free_algebraic_expressions(actual, exp_count);
1497 free_algebraic_expressions(expected, exp_count);
1498 array_free(actual);
1499 AST_Free(master_ast);
1500}
1501
1502void test_ExpressionExecute() {
1503 GraphContext *gc = QueryCtx_GetGraphCtx();

Callers

nothing calls this directly

Calls 7

array_lenFunction · 0.85
array_freeFunction · 0.85
AST_FreeFunction · 0.85

Tested by

no test coverage detected