void testCap_getEnd(CuTest* testCase) { cactusCapTestSetup(); CuAssertTrue(testCase, cap_getEnd(rootCap) == end_getReverse(end)); CuAssertTrue(testCase, cap_getEnd(cap_getReverse(rootCap)) == end); CuAssertTrue(testCase, cap_getEnd(leaf2Cap) == end); CuAssertTrue(testCase, cap_getEnd(cap_getReverse(leaf2Cap)) == end_getReverse(end)); cactusCapTestTeardown(); }
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(); }
Block *block_construct2(Name name, int64_t length, End *leftEnd, End *rightEnd, Flower *flower) { Block *block; block = st_malloc(sizeof(Block)); block->rBlock = st_malloc(sizeof(Block)); block->rBlock->rBlock = block; block->blockContents = st_malloc(sizeof(BlockContents)); block->rBlock->blockContents = block->blockContents; block->orientation = 1; block->rBlock->orientation = 0; block->blockContents->name = name; block->blockContents->segments = stSortedSet_construct3(blockConstruct_constructP, NULL); block->blockContents->length = length; block->blockContents->flower = flower; block->leftEnd = leftEnd; end_setBlock(leftEnd, block); block->rBlock->leftEnd = end_getReverse(rightEnd); end_setBlock(rightEnd, block); flower_addBlock(flower, block); return block; }
void testEnd_getSide(CuTest *testCase) { cactusEndTestSetup(); Block *block = block_construct(10, flower); End *_5End = block_get5End(block); End *_3End = block_get3End(block); CuAssertTrue(testCase, end_getSide(end)); CuAssertTrue(testCase, !end_getSide(end_getReverse(end))); CuAssertTrue(testCase, end_getSide(_5End)); CuAssertTrue(testCase, !end_getSide(_3End)); CuAssertTrue(testCase, end_getSide(end_getReverse(_3End))); CuAssertTrue(testCase, !end_getSide(end_getReverse(_5End))); cactusEndTestTeardown(); }
void testEnd_getName(CuTest* testCase) { cactusEndTestSetup(); CuAssertTrue(testCase, end_getName(end) != NULL_NAME); CuAssertTrue(testCase, flower_getEnd(flower, end_getName(end)) == end); CuAssertTrue(testCase, flower_getEnd(flower, end_getName(end_getReverse(end))) == end); cactusEndTestTeardown(); }
void block_check(Block *block) { //Check is connected to flower properly cactusCheck(flower_getBlock(block_getFlower(block), block_getName(block)) == block_getPositiveOrientation(block)); //Check we have actually set built blocks for the flower.. cactusCheck(flower_builtBlocks(block_getFlower(block))); //Checks the two ends are block ends. End *_5End = block_get5End(block); End *_3End = block_get3End(block); cactusCheck(end_isBlockEnd(_5End)); cactusCheck(end_isBlockEnd(_3End)); cactusCheck(end_getOrientation(_5End) == block_getOrientation(block)); cactusCheck(end_getOrientation(_3End) == block_getOrientation(block)); cactusCheck(end_getBlock(_5End) == block); cactusCheck(end_getBlock(_3End) == block); cactusCheck(end_getSide(_5End)); //Check the sides of the ends are consistent. cactusCheck(!end_getSide(_3End)); cactusCheck(block_getLength(block) > 0); //check block has non-zero length //Check reverse Block *rBlock = block_getReverse(block); cactusCheck(rBlock != NULL); cactusCheck(block_getReverse(block) == rBlock); cactusCheck(block_getOrientation(block) == !block_getOrientation(rBlock)); cactusCheck(block_getLength(block) == block_getLength(rBlock)); cactusCheck(block_get5End(block) == end_getReverse(block_get3End(rBlock))); cactusCheck(block_get3End(block) == end_getReverse(block_get5End(rBlock))); cactusCheck(block_getInstanceNumber(block) == block_getInstanceNumber(rBlock)); if(block_getInstanceNumber(block) > 0) { cactusCheck(block_getFirst(block) == segment_getReverse(block_getFirst(rBlock))); if(block_getRootInstance(block) == NULL) { cactusCheck(block_getRootInstance(rBlock) == NULL); } else { cactusCheck(block_getRootInstance(block) == segment_getReverse(block_getRootInstance(rBlock))); } } //For each segment calls segment_check. Block_InstanceIterator *iterator = block_getInstanceIterator(block); Segment *segment; while((segment = block_getNext(iterator)) != NULL) { segment_check(segment); } block_destructInstanceIterator(iterator); }
void flower_check(Flower *flower) { eventTree_check(flower_getEventTree(flower)); Flower_GroupIterator *groupIterator = flower_getGroupIterator(flower); Group *group; while ((group = flower_getNextGroup(groupIterator)) != NULL) { group_check(group); } flower_destructGroupIterator(groupIterator); Flower_ChainIterator *chainIterator = flower_getChainIterator(flower); Chain *chain; while ((chain = flower_getNextChain(chainIterator)) != NULL) { chain_check(chain); } flower_destructCapIterator(chainIterator); //We check built trees in here. Flower_EndIterator *endIterator = flower_getEndIterator(flower); End *end; while ((end = flower_getNextEnd(endIterator)) != NULL) { end_check(end); end_check(end_getReverse(end)); //We will test everything backwards also. } flower_destructEndIterator(endIterator); if (flower_builtFaces(flower)) { Flower_FaceIterator *faceIterator = flower_getFaceIterator(flower); Face *face; while ((face = flower_getNextFace(faceIterator)) != NULL) { face_check(face); } flower_destructFaceIterator(faceIterator); face_checkFaces(flower); } else { cactusCheck(flower_getFaceNumber(flower) == 0); } if (flower_builtBlocks(flower)) { //Note that a flower for which the blocks are not yet built must be a leaf. Flower_BlockIterator *blockIterator = flower_getBlockIterator(flower); Block *block; while ((block = flower_getNextBlock(blockIterator)) != NULL) { block_check(block); block_check(block_getReverse(block)); //We will test everything backwards also. } flower_destructBlockIterator(blockIterator); } else { cactusCheck(flower_isLeaf(flower)); //Defensive cactusCheck(flower_isTerminal(flower)); //Checks that a flower without built blocks is a leaf and does not //contain any blocks. } Flower_SequenceIterator *sequenceIterator = flower_getSequenceIterator(flower); Sequence *sequence; while ((sequence = flower_getNextSequence(sequenceIterator)) != NULL) { sequence_check(sequence); } flower_destructSequenceIterator(sequenceIterator); }
void testEnd_getOtherBlockEnd(CuTest *testCase) { cactusEndTestSetup(); Block *block = block_construct(10, flower); End *leftEnd = block_get5End(block); End *rightEnd = block_get3End(block); CuAssertTrue(testCase, end_getOtherBlockEnd(end) == NULL); CuAssertTrue(testCase, end_getOtherBlockEnd(end_getReverse(end)) == NULL); CuAssertTrue(testCase, end_getOtherBlockEnd(leftEnd) == rightEnd); CuAssertTrue(testCase, end_getOtherBlockEnd(rightEnd) == leftEnd); CuAssertTrue(testCase, end_getOtherBlockEnd(end_getReverse(leftEnd)) == end_getReverse(rightEnd)); CuAssertTrue(testCase, end_getOtherBlockEnd(end_getReverse(rightEnd)) == end_getReverse(leftEnd)); cactusEndTestTeardown(); }
void testEnd_getBlock(CuTest* testCase) { cactusEndTestSetup(); Block *block = block_construct(10, flower); End *leftEnd = block_get5End(block); End *rightEnd = block_get3End(block); CuAssertTrue(testCase, end_getBlock(end) == NULL); CuAssertTrue(testCase, end_getBlock(end_getReverse(end)) == NULL); CuAssertTrue(testCase, end_getBlock(leftEnd) == block); CuAssertTrue(testCase, end_getBlock(end_getReverse(leftEnd)) == block_getReverse(block)); CuAssertTrue(testCase, block_getOrientation(block) == end_getOrientation(leftEnd)); CuAssertTrue(testCase, end_getBlock(rightEnd) == block); CuAssertTrue(testCase, end_getBlock(end_getReverse(rightEnd)) == block_getReverse(block)); CuAssertTrue(testCase, block_getOrientation(block) == end_getOrientation(rightEnd)); cactusEndTestTeardown(); }
void testEnd_getCapForEvent(CuTest* testCase) { cactusEndTestSetup(); CuAssertPtrEquals(testCase, end_getCapForEvent(end_getReverse(end), event_getName(rootEvent)), rootCap); Cap *cap = end_getCapForEvent(end, event_getName(leafEvent)); CuAssertTrue(testCase, cap == cap_getReverse(leaf1Cap) || cap == leaf2Cap || cap == cap_getReverse(leaf3Cap)); CuAssertTrue(testCase, end_getCapForEvent(end, NULL_NAME) == NULL); cactusEndTestTeardown(); }
void testEnd_instanceIterator(CuTest* testCase) { cactusEndTestSetup(); End_InstanceIterator *iterator = end_getInstanceIterator(end); CuAssertTrue(testCase, iterator != NULL); CuAssertTrue(testCase, end_getNext(iterator) == cap_getReverse(rootCap)); CuAssertTrue(testCase, end_getNext(iterator) == cap_getReverse(leaf1Cap)); End_InstanceIterator *iterator2 = end_copyInstanceIterator(iterator); CuAssertTrue(testCase, end_getNext(iterator) == leaf2Cap); CuAssertTrue(testCase, end_getNext(iterator) == cap_getReverse(leaf3Cap)); CuAssertTrue(testCase, end_getNext(iterator) == NULL); CuAssertTrue(testCase, end_getPrevious(iterator) == cap_getReverse(leaf3Cap)); CuAssertTrue(testCase, end_getPrevious(iterator) == leaf2Cap); CuAssertTrue(testCase, end_getPrevious(iterator) == cap_getReverse(leaf1Cap)); CuAssertTrue(testCase, end_getPrevious(iterator) == cap_getReverse(rootCap)); CuAssertTrue(testCase, end_getPrevious(iterator) == NULL); CuAssertTrue(testCase, end_getNext(iterator2) == leaf2Cap); CuAssertTrue(testCase, end_getNext(iterator2) == cap_getReverse(leaf3Cap)); CuAssertTrue(testCase, end_getNext(iterator2) == NULL); CuAssertTrue(testCase, end_getPrevious(iterator2) == cap_getReverse(leaf3Cap)); CuAssertTrue(testCase, end_getPrevious(iterator2) == leaf2Cap); CuAssertTrue(testCase, end_getPrevious(iterator2) == cap_getReverse(leaf1Cap)); CuAssertTrue(testCase, end_getPrevious(iterator2) == cap_getReverse(rootCap)); CuAssertTrue(testCase, end_getPrevious(iterator2) == NULL); end_destructInstanceIterator(iterator); end_destructInstanceIterator(iterator2); iterator = end_getInstanceIterator(end_getReverse(end)); CuAssertTrue(testCase, end_getNext(iterator) == rootCap); CuAssertTrue(testCase, end_getNext(iterator) == leaf1Cap); CuAssertTrue(testCase, end_getNext(iterator) == cap_getReverse(leaf2Cap)); CuAssertTrue(testCase, end_getNext(iterator) == leaf3Cap); CuAssertTrue(testCase, end_getNext(iterator) == NULL); CuAssertTrue(testCase, end_getPrevious(iterator) == leaf3Cap); CuAssertTrue(testCase, end_getPrevious(iterator) == cap_getReverse(leaf2Cap)); CuAssertTrue(testCase, end_getPrevious(iterator) == leaf1Cap); CuAssertTrue(testCase, end_getPrevious(iterator) == rootCap); CuAssertTrue(testCase, end_getPrevious(iterator) == NULL); end_destructInstanceIterator(iterator); cactusEndTestTeardown(); }
End *block_get3End(Block *block) { return end_getReverse(block->rBlock->leftEnd); }
void testCap_getOrientation(CuTest* testCase) { cactusCapTestSetup(); CuAssertTrue(testCase, cap_getOrientation(rootCap) == end_getOrientation(cap_getEnd(rootCap))); CuAssertTrue(testCase, cap_getOrientation(leaf1Cap) == end_getOrientation(cap_getEnd(leaf1Cap))); CuAssertTrue(testCase, cap_getOrientation(leaf2Cap) == end_getOrientation(cap_getEnd(leaf2Cap))); CuAssertTrue(testCase, cap_getOrientation(cap_getReverse(rootCap)) == end_getOrientation(end_getReverse(cap_getEnd(rootCap)))); CuAssertTrue(testCase, cap_getOrientation(cap_getReverse(leaf1Cap)) == end_getOrientation(end_getReverse(cap_getEnd(leaf1Cap)))); CuAssertTrue(testCase, cap_getOrientation(cap_getReverse(leaf2Cap)) == end_getOrientation(end_getReverse(cap_getEnd(leaf2Cap)))); CuAssertTrue(testCase, cap_getOrientation(leaf1Cap) == cap_getOrientation(rootCap)); CuAssertTrue(testCase, cap_getOrientation(leaf1Cap) != cap_getOrientation(leaf2Cap)); cactusCapTestTeardown(); }
void testEnd_getReverse(CuTest* testCase) { cactusEndTestSetup(); CuAssertTrue(testCase, end_getReverse(end) != NULL); CuAssertTrue(testCase, end_getReverse(end_getReverse(end)) == end); cactusEndTestTeardown(); }
void testEnd_getOrientation(CuTest* testCase) { cactusEndTestSetup(); CuAssertTrue(testCase, end_getOrientation(end)); CuAssertTrue(testCase, !end_getOrientation(end_getReverse(end))); cactusEndTestTeardown(); }