예제 #1
0
void testEvent_serialisation(CuTest* testCase) {
	cactusEventTestSetup();
	int64_t i;
	void *vA = binaryRepresentation_makeBinaryRepresentation(leafEvent1,
			(void (*)(void *, void (*)(const void *, size_t, size_t)))event_writeBinaryRepresentation, &i);
	CuAssertTrue(testCase, i > 0);
	event_destruct(leafEvent1);
	void *vA2 = vA;
	leafEvent1 = event_loadFromBinaryRepresentation(&vA2, eventTree);
	free(vA);
	nestedTest = 1;
	testEvent_getParent(testCase);
	testEvent_getName(testCase);
	testEvent_getHeader(testCase);
	testEvent_getBranchLength(testCase);
	testEvent_getSubTreeBranchLength(testCase);
	testEvent_getSubTreeEventNumber(testCase);
	testEvent_getChildNumber(testCase);
	//testEvent_getChild(testCase); -- won't work as doesn't preserve order of leaves, which is okay -- here's a replacement.
	CuAssertTrue(testCase, event_getChild(rootEvent, 0) == internalEvent);
	CuAssertTrue(testCase, event_getChild(internalEvent, 0) == leafEvent2);
	CuAssertTrue(testCase, event_getChild(internalEvent, 1) == leafEvent1);

	testEvent_getEventTree(testCase);
	testEvent_isAncestor(testCase);
	testEvent_isDescendant(testCase);
	testEvent_isSibling(testCase);
	testEvent_isOutgroup(testCase);
	nestedTest = 0;
	cactusEventTestTeardown();
}
예제 #2
0
EventTree *eventTree_loadFromBinaryRepresentation(void **binaryString, CactusDisk *cactusDisk) {
	EventTree *eventTree;
	Name name;
	eventTree = NULL;
	if(binaryRepresentation_peekNextElementType(*binaryString) == CODE_EVENT_TREE) {
		binaryRepresentation_popNextElementType(binaryString);
		name = binaryRepresentation_getName(binaryString);
		eventTree = eventTree_construct(cactusDisk, name);
		while(event_loadFromBinaryRepresentation(binaryString, eventTree) != NULL) {
			;
		}
		assert(binaryRepresentation_peekNextElementType(*binaryString) == CODE_EVENT_TREE);
		binaryRepresentation_popNextElementType(binaryString);
	}
	return eventTree;
}