void testEnd_getInstance(CuTest* testCase) { cactusEndTestSetup(); CuAssertTrue(testCase, end_getInstance(end, cap_getName(rootCap)) == cap_getReverse(rootCap)); CuAssertTrue(testCase, end_getInstance(end, cap_getName(leaf1Cap)) == cap_getReverse(leaf1Cap)); CuAssertTrue(testCase, end_getInstance(end, cap_getName(leaf2Cap)) == leaf2Cap); cactusEndTestTeardown(); }
void testEnd_copyConstruct(CuTest* testCase) { cactusEndTestSetup(); Flower *flower2 = flower_construct(cactusDisk); eventTree_copyConstruct(eventTree, flower2, testEnd_copyConstructP); sequence_construct(metaSequence, flower2); End *end2 = end_copyConstruct(end, flower2); CuAssertTrue(testCase, end_getName(end2) != NULL_NAME); CuAssertTrue(testCase, end_getName(end2) == end_getName(end)); CuAssertTrue(testCase, flower_getEnd(flower2, end_getName(end2)) == end2); CuAssertTrue(testCase, cap_getName(end_getInstance(end2, cap_getName(rootCap))) == cap_getName(rootCap)); CuAssertTrue(testCase, cap_getName(end_getInstance(end2, cap_getName(leaf1Cap))) == cap_getName(leaf1Cap)); CuAssertTrue(testCase, cap_getName(end_getInstance(end2, cap_getName(leaf2Cap))) == cap_getName(leaf2Cap)); cactusEndTestTeardown(); }
void testEnd_serialisation(CuTest* testCase) { cactusEndTestSetup(); Name rootInstanceName = cap_getName(rootCap); Name leaf1InstanceName = cap_getName(leaf1Cap); Name leaf2InstanceName = cap_getName(leaf2Cap); Name leaf3InstanceName = cap_getName(leaf3Cap); int64_t i; void *vA = binaryRepresentation_makeBinaryRepresentation(end, (void(*)(void *, void(*)(const void *, size_t, size_t))) end_writeBinaryRepresentation, &i); CuAssertTrue(testCase, i > 0); end_destruct(end); void *vA2 = vA; end = end_loadFromBinaryRepresentation(&vA2, flower); rootCap = cap_getReverse(end_getInstance(end, rootInstanceName)); leaf1Cap = cap_getReverse(end_getInstance(end, leaf1InstanceName)); leaf2Cap = end_getInstance(end, leaf2InstanceName); leaf3Cap = cap_getReverse(end_getInstance(end, leaf3InstanceName)); CuAssertTrue(testCase, leaf3Cap != NULL); free(vA); nestedTest = 1; testEnd_copyConstruct(testCase); testEnd_getName(testCase); testEnd_getOrientation(testCase); testEnd_getReverse(testCase); testEnd_getSide(testCase); testEnd_getFlower(testCase); testEnd_getBlock(testCase); testEnd_getOtherBlockEnd(testCase); testEnd_getGroup(testCase); testEnd_setGroup(testCase); testEnd_getInstanceNumber(testCase); testEnd_getInstance(testCase); testEnd_getFirst(testCase); testEnd_getSetRootInstance(testCase); testEnd_instanceIterator(testCase); testEnd_isBlockOrStubEnd(testCase); testEnd_isAttachedOrFree(testCase); testEnd_getCapForEvent(testCase); nestedTest = 0; cactusEndTestTeardown(); }
static Cap *copyCapToParent(Cap *cap, stList *recoveredCaps) { /* * Get the adjacent stub end by looking at the reference adjacency in the parent. */ End *end = cap_getEnd(cap); assert(end != NULL); Group *parentGroup = flower_getParentGroup(end_getFlower(end)); assert(parentGroup != NULL); End *copiedEnd = end_copyConstruct(end, group_getFlower(parentGroup)); end_setGroup(copiedEnd, parentGroup); //Set group Cap *copiedCap = end_getInstance(copiedEnd, cap_getName(cap)); assert(copiedCap != NULL); copiedCap = cap_getStrand(copiedCap) ? copiedCap : cap_getReverse(copiedCap); if (!cap_getSide(copiedCap)) { stList_append(recoveredCaps, copiedCap); } return copiedCap; }