void testEnd_getSetRootInstance(CuTest* testCase) { cactusEndTestSetup(); CuAssertTrue(testCase, end_getRootInstance(end) == cap_getReverse(rootCap)); CuAssertTrue(testCase, end_getRootInstance(end_getReverse(end)) == rootCap); End *end2 = end_construct(0, flower); CuAssertTrue(testCase, end_getRootInstance(end2) == NULL); CuAssertTrue(testCase, end_getRootInstance(end_getReverse(end2)) == NULL); cactusEndTestTeardown(); }
void testBlock_getSetRootInstance(CuTest *testCase) { cactusBlockTestSetup(); Block *block2 = block_construct(1, flower); CuAssertTrue(testCase, block_getRootInstance(block2) == NULL); block_destruct(block2); //block_setRootInstance(block, segment_getReverse(rootSegment)); //set in the constructor code of the test. CuAssertTrue(testCase, block_getRootInstance(block) == segment_getReverse(rootSegment)); CuAssertTrue(testCase, end_getRootInstance(block_get5End(block)) == segment_get5Cap(segment_getReverse(rootSegment))); CuAssertTrue(testCase, end_getRootInstance(block_get3End(block)) == segment_get3Cap(segment_getReverse(rootSegment))); cactusBlockTestTeardown(); }
void testCap_getTopCap(CuTest* testCase) { cactusCapTestSetup(); End *end1 = end_construct(0, flower); End *end2 = end_construct(0, flower); End *end3 = end_construct(0, flower); Event *intermediateEvent = event_construct4(NULL, 0.0, rootEvent, leafEvent, eventTree); Cap *cap1T = cap_construct(end1, rootEvent); Cap *cap1I = cap_construct(end1, intermediateEvent); Cap *cap1L1 = cap_construct(end1, leafEvent); Cap *cap1L2 = cap_construct(end1, leafEvent); cap_makeParentAndChild(cap1I, cap1L1); cap_makeParentAndChild(cap1I, cap1L2); cap_makeParentAndChild(cap1T, cap1I); end_setRootInstance(end1, cap1T); assert(end_getRootInstance(end1) == cap1T); CuAssertTrue(testCase, cap_getTopCap(cap1L1) == NULL); CuAssertTrue(testCase, cap_getTopCap(cap_getReverse(cap1L1)) == NULL); CuAssertTrue(testCase, cap_getTopCap(cap1L2) == NULL); CuAssertTrue(testCase, cap_getTopCap(cap1I) == NULL); Cap *cap2T = cap_construct(end2, rootEvent); Cap *cap2L = cap_construct(end2, leafEvent); cap_makeParentAndChild(cap2T, cap2L); end_setRootInstance(end2, cap2T); cap_makeAdjacent(cap1L1, cap2L); CuAssertTrue(testCase, cap_getTopCap(cap1L1) == cap1T); CuAssertTrue(testCase, cap_getTopCap(cap_getReverse(cap1L1)) == cap_getReverse(cap1T)); CuAssertTrue(testCase, cap_getTopCap(cap1I) == NULL); Cap *cap3T = cap_construct(end3, rootEvent); Cap *cap3I = cap_construct(end3, intermediateEvent); cap_makeParentAndChild(cap3T, cap3I); end_setRootInstance(end3, cap3T); cap_makeAdjacent(cap1I, cap3I); cap_makeAdjacent(cap1T, cap3T); CuAssertTrue(testCase, cap_getTopCap(cap1L1) == cap1I); CuAssertTrue(testCase, cap_getTopCap(cap_getReverse(cap1L1)) == cap_getReverse(cap1I)); CuAssertTrue(testCase, cap_getTopCap(cap1I) == cap1T); CuAssertTrue(testCase, cap_getTopCap(cap_getReverse(cap1I)) == cap_getReverse(cap1T)); CuAssertTrue(testCase, cap_getTopCap(cap1T) == NULL); cactusCapTestTeardown(); }
Segment *block_getRootInstance(Block *block) { Cap *cap = end_getRootInstance(block_get5End(block)); return cap != NULL ? cap_getSegment(cap) : NULL; }