| 195 | } |
| 196 | |
| 197 | void test_set() { |
| 198 | // simple match and set property |
| 199 | char *q = "MATCH (n) SET n.v=1"; |
| 200 | AST *ast = buildAST(q); |
| 201 | uint *segmentIndices = getASTSegmentIndices(ast); |
| 202 | TEST_ASSERT(1 == array_len(segmentIndices)); |
| 203 | |
| 204 | AST *astSegment = AST_NewSegment(ast, 0, segmentIndices[0]); |
| 205 | TEST_ASSERT(1 == raxSize(astSegment->referenced_entities)); |
| 206 | TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"n", 1)); |
| 207 | array_free(segmentIndices); |
| 208 | AST_Free(astSegment); |
| 209 | AST_Free(ast); |
| 210 | |
| 211 | // path match and set property |
| 212 | q = "MATCH (n)-[e]->(x)-[]->(m) SET n.v=x.v"; |
| 213 | ast = buildAST(q); |
| 214 | segmentIndices = getASTSegmentIndices(ast); |
| 215 | TEST_ASSERT(1 == array_len(segmentIndices)); |
| 216 | astSegment = AST_NewSegment(ast, 0, segmentIndices[0]); |
| 217 | TEST_ASSERT(2 == raxSize(astSegment->referenced_entities)); |
| 218 | TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"n", 1)); |
| 219 | TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"x", 1)); |
| 220 | TEST_ASSERT(raxNotFound == raxFind(astSegment->referenced_entities, (unsigned char *)"e", 1)); |
| 221 | TEST_ASSERT(raxNotFound == raxFind(astSegment->referenced_entities, (unsigned char *)"m", 1)); |
| 222 | array_free(segmentIndices); |
| 223 | AST_Free(astSegment); |
| 224 | AST_Free(ast); |
| 225 | |
| 226 | // reference from MATCH and SET caluse |
| 227 | q = "MATCH (n)-[e:r]->(m) SET n.v=1"; |
| 228 | ast = buildAST(q); |
| 229 | segmentIndices = getASTSegmentIndices(ast); |
| 230 | TEST_ASSERT(1 == array_len(segmentIndices)); |
| 231 | astSegment = AST_NewSegment(ast, 0, segmentIndices[0]); |
| 232 | TEST_ASSERT(1 == raxSize(astSegment->referenced_entities)); |
| 233 | TEST_ASSERT(raxNotFound != raxFind(astSegment->referenced_entities, (unsigned char *)"n", 1)); |
| 234 | TEST_ASSERT(raxNotFound == raxFind(astSegment->referenced_entities, (unsigned char *)"e", 1)); |
| 235 | TEST_ASSERT(raxNotFound == raxFind(astSegment->referenced_entities, (unsigned char *)"m", 1)); |
| 236 | array_free(segmentIndices); |
| 237 | AST_Free(astSegment); |
| 238 | AST_Free(ast); |
| 239 | } |
| 240 | |
| 241 | void test_merge() { |
| 242 | // simple merge |
nothing calls this directly
no test coverage detected