void testEnd_getGroup(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_getGroup(end) == NULL); Group *group = group_construct(flower, flower2); CuAssertTrue(testCase, end_getGroup(end) == group); CuAssertTrue(testCase, end_getGroup(end2) == NULL); cactusEndTestTeardown(); }
void testEventTree_copyConstruct(CuTest* testCase) { cactusEventTreeTestSetup(); Flower *flower2 = flower_construct(cactusDisk); EventTree *eventTree2 = eventTree_copyConstruct(eventTree, flower2, unaryEventFunction); CuAssertIntEquals(testCase, eventTree_getEventNumber(eventTree), eventTree_getEventNumber(eventTree2)); CuAssertTrue(testCase, event_getName(eventTree_getEvent(eventTree2, event_getName(rootEvent))) == event_getName(rootEvent)); CuAssertTrue(testCase, event_getName(eventTree_getEvent(eventTree2, event_getName(internalEvent))) == event_getName(internalEvent)); CuAssertTrue(testCase, event_getName(eventTree_getEvent(eventTree2, event_getName(leafEvent1))) == event_getName(leafEvent1)); CuAssertTrue(testCase, event_getName(eventTree_getEvent(eventTree2, event_getName(leafEvent2))) == event_getName(leafEvent2)); CuAssertTrue(testCase, event_isOutgroup(eventTree_getEvent(eventTree2, event_getName(leafEvent1)))); CuAssertTrue(testCase, !event_isOutgroup(eventTree_getEvent(eventTree2, event_getName(leafEvent2)))); cactusEventTreeTestTeardown(); }
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 testBlock_getChain(CuTest* testCase) { cactusBlockTestSetup(); Block *block2 = block_construct(2, flower); Flower *flower2 = flower_construct(cactusDisk); eventTree_copyConstruct(flower_getEventTree(flower), flower2, NULL); end_copyConstruct(block_get3End(block), flower2); end_copyConstruct(block_get5End(block2), flower2); Group *group = group_construct(flower, flower2); Chain *chain = chain_construct(flower); link_construct(block_get3End(block), block_get5End(block2), group, chain); CuAssertTrue(testCase, block_getChain(block_construct(2, flower)) == NULL); CuAssertTrue(testCase, block_getChain(block) == chain); CuAssertTrue(testCase, block_getChain(block2) == chain); cactusBlockTestTeardown(); }
void testEventTree_addSiblingUnaryEvent(CuTest *testCase) { cactusEventTreeTestSetup(); //Create two sibling flowers with the basic event tree.. //then try adding events from on into the other. Group *group1 = group_construct2(flower); Group *group2 = group_construct2(flower); Flower *flower2 = flower_construct(cactusDisk); Flower *flower3 = flower_construct(cactusDisk); flower_setParentGroup(flower2, group1); flower_setParentGroup(flower3, group2); EventTree *eventTree2 = eventTree_copyConstruct(flower_getEventTree(flower), flower2, NULL); Event *parentUnaryEvent1 = event_construct4("UNARY1", 0.1, internalEvent, leafEvent1, eventTree); Event *parentUnaryEvent2 = event_construct4("UNARY2", 0.1, parentUnaryEvent1, leafEvent1, eventTree); Event *parentUnaryEvent3 = event_construct4("UNARY3", 0.1, internalEvent, leafEvent2, eventTree); //now event tree contains the added unary events. EventTree *eventTree3 = eventTree_copyConstruct(flower_getEventTree(flower), flower3, NULL); //add a couple of denovo events into the new event tree Event *internalEventChild = eventTree_getEvent(eventTree3, event_getName(internalEvent)); Event *unaryEvent1 = eventTree_getEvent(eventTree3, event_getName(parentUnaryEvent1)); Event *unaryEvent2 = eventTree_getEvent(eventTree3, event_getName(parentUnaryEvent2)); Event *unaryEvent3 = eventTree_getEvent(eventTree3, event_getName(parentUnaryEvent3)); Event *unaryEvent4 = event_construct4("UNARY4", 0.1, internalEventChild, unaryEvent3, eventTree3); Event *unaryEvent5 = event_construct4("UNARY5", 0.1, internalEventChild, unaryEvent4, eventTree3); //Now event-tree 2 does not contain the unary events but event-tree 3 does.. CuAssertTrue(testCase, eventTree_getEvent(eventTree2, event_getName(unaryEvent1)) == NULL); CuAssertTrue(testCase, eventTree_getEvent(eventTree2, event_getName(unaryEvent2)) == NULL); CuAssertTrue(testCase, eventTree_getEvent(eventTree2, event_getName(unaryEvent3)) == NULL); CuAssertTrue(testCase, eventTree_getEvent(eventTree2, event_getName(unaryEvent4)) == NULL); CuAssertTrue(testCase, eventTree_getEvent(eventTree2, event_getName(unaryEvent5)) == NULL); eventTree_addSiblingUnaryEvent(eventTree2, unaryEvent1); Event *unaryEvent12 = eventTree_getEvent(eventTree2, event_getName(unaryEvent1)); CuAssertTrue(testCase, unaryEvent12 != NULL); CuAssertTrue(testCase, event_getName(event_getParent(unaryEvent12)) == event_getName(internalEvent)); CuAssertTrue(testCase, event_getChildNumber(unaryEvent12) == 1); CuAssertTrue(testCase, event_getName(event_getChild(unaryEvent12, 0)) == event_getName(leafEvent1)); eventTree_addSiblingUnaryEvent(eventTree2, unaryEvent2); Event *unaryEvent22 = eventTree_getEvent(eventTree2, event_getName(unaryEvent2)); CuAssertTrue(testCase, unaryEvent22 != NULL); CuAssertTrue(testCase, event_getName(event_getParent(unaryEvent22)) == event_getName(unaryEvent1)); CuAssertTrue(testCase, event_getChildNumber(unaryEvent22) == 1); CuAssertTrue(testCase, event_getName(event_getChild(unaryEvent22, 0)) == event_getName(leafEvent1)); eventTree_addSiblingUnaryEvent(eventTree2, unaryEvent3); Event *unaryEvent32 = eventTree_getEvent(eventTree2, event_getName(unaryEvent3)); CuAssertTrue(testCase, unaryEvent32 != NULL); CuAssertTrue(testCase, event_getName(event_getParent(unaryEvent32)) == event_getName(internalEvent)); CuAssertTrue(testCase, event_getChildNumber(unaryEvent32) == 1); CuAssertTrue(testCase, event_getName(event_getChild(unaryEvent32, 0)) == event_getName(leafEvent2)); eventTree_addSiblingUnaryEvent(eventTree2, unaryEvent4); Event *unaryEvent42 = eventTree_getEvent(eventTree2, event_getName(unaryEvent4)); CuAssertTrue(testCase, unaryEvent42 != NULL); CuAssertTrue(testCase, event_getName(event_getParent(unaryEvent42)) == event_getName(internalEvent)); CuAssertTrue(testCase, event_getChildNumber(unaryEvent42) == 1); CuAssertTrue(testCase, event_getName(event_getChild(unaryEvent42, 0)) == event_getName(unaryEvent3)); eventTree_addSiblingUnaryEvent(eventTree2, unaryEvent5); Event *unaryEvent52 = eventTree_getEvent(eventTree2, event_getName(unaryEvent5)); CuAssertTrue(testCase, unaryEvent52 != NULL); CuAssertTrue(testCase, event_getName(event_getParent(unaryEvent52)) == event_getName(internalEvent)); CuAssertTrue(testCase, event_getChildNumber(unaryEvent52) == 1); CuAssertTrue(testCase, event_getName(event_getChild(unaryEvent52, 0)) == event_getName(unaryEvent4)); //uglyf("Event-tree-1 %s\n", eventTree_makeNewickString(eventTree)); //uglyf("Event-tree-2 %s\n", eventTree_makeNewickString(eventTree3)); //uglyf("Event-tree-3 %s\n", eventTree_makeNewickString(eventTree2)); cactusEventTreeTestTeardown(); }