| 1500 | } |
| 1501 | |
| 1502 | void test_ExpressionExecute() { |
| 1503 | GraphContext *gc = QueryCtx_GetGraphCtx(); |
| 1504 | Graph *g = gc->g; |
| 1505 | |
| 1506 | // "MATCH (p:Person)-[ef:friend]->(f:Person)-[ev:visit]->(c:City)-[ew:war]->(e:City) RETURN p, e" |
| 1507 | const char *q = query_no_intermidate_return_nodes; |
| 1508 | AST *master_ast; |
| 1509 | AlgebraicExpression **ae = build_algebraic_expression(q, &master_ast); |
| 1510 | uint exp_count = array_len(ae); |
| 1511 | TEST_ASSERT(exp_count == 1); |
| 1512 | |
| 1513 | AlgebraicExpression *exp = ae[0]; |
| 1514 | TEST_ASSERT(strcmp(AlgebraicExpression_Src(exp), "p") == 0); |
| 1515 | TEST_ASSERT(strcmp(AlgebraicExpression_Dest(exp), "e") == 0); |
| 1516 | |
| 1517 | RG_Matrix res; |
| 1518 | RG_Matrix_new(&res, GrB_BOOL, Graph_RequiredMatrixDim(g), |
| 1519 | Graph_RequiredMatrixDim(g)); |
| 1520 | AlgebraicExpression_Eval(exp, res); |
| 1521 | |
| 1522 | // Validate result matrix. |
| 1523 | GrB_Index ncols, nrows; |
| 1524 | RG_Matrix_ncols(&ncols, res); |
| 1525 | RG_Matrix_nrows(&nrows, res); |
| 1526 | assert(ncols == Graph_RequiredMatrixDim(g)); |
| 1527 | assert(nrows == Graph_RequiredMatrixDim(g)); |
| 1528 | |
| 1529 | GrB_Matrix expected = NULL; |
| 1530 | GrB_Index expected_entries[6] = {1, 2, 0, 3, 1, 3}; |
| 1531 | GrB_Matrix_new(&expected, GrB_BOOL, nrows, ncols); |
| 1532 | for(int i = 0; i < 6; i += 2) { |
| 1533 | GrB_Matrix_setElement_BOOL(expected, true, expected_entries[i], |
| 1534 | expected_entries[i + 1]); |
| 1535 | } |
| 1536 | |
| 1537 | assert(_compare_matrices(expected, res)); |
| 1538 | |
| 1539 | // Clean up |
| 1540 | RG_Matrix_free(&res); |
| 1541 | GrB_Matrix_free(&expected); |
| 1542 | free_algebraic_expressions(ae, exp_count); |
| 1543 | array_free(ae); |
| 1544 | AST_Free(master_ast); |
| 1545 | } |
| 1546 | |
| 1547 | void test_RemoveOperand() { |
| 1548 | GrB_Matrix A = GrB_NULL; |
nothing calls this directly
no test coverage detected