Flower *flower_loadFromBinaryRepresentation(void **binaryString, CactusDisk *cactusDisk) { Flower *flower = NULL; bool buildFaces; if (binaryRepresentation_peekNextElementType(*binaryString) == CODE_FLOWER) { binaryRepresentation_popNextElementType(binaryString); flower = flower_construct3(binaryRepresentation_getName(binaryString), cactusDisk); //Constructed without an event tree. flower_setBuiltBlocks(flower, binaryRepresentation_getBool(binaryString)); flower_setBuiltTrees(flower, binaryRepresentation_getBool(binaryString)); buildFaces = binaryRepresentation_getBool(binaryString); flower->parentFlowerName = binaryRepresentation_getName(binaryString); eventTree_loadFromBinaryRepresentation(binaryString, flower); while (sequence_loadFromBinaryRepresentation(binaryString, flower) != NULL) ; while (end_loadFromBinaryRepresentation(binaryString, flower) != NULL) ; while (block_loadFromBinaryRepresentation(binaryString, flower) != NULL) ; while (group_loadFromBinaryRepresentation(binaryString, flower) != NULL) ; while (chain_loadFromBinaryRepresentation(binaryString, flower) != NULL) ; flower_setBuildFaces(flower, buildFaces); assert(binaryRepresentation_popNextElementType(binaryString) == CODE_FLOWER); } return flower; }
void testEventTree_serialisation(CuTest* testCase) { cactusEventTreeTestSetup(); int64_t i; void *vA = binaryRepresentation_makeBinaryRepresentation(eventTree, (void (*)(void *, void (*)(const void *, size_t, size_t)))eventTree_writeBinaryRepresentation, &i); CuAssertTrue(testCase, i > 0); eventTree_destruct(eventTree); void *vA2 = vA; eventTree = eventTree_loadFromBinaryRepresentation(&vA2, flower); rootEvent = eventTree_getRootEvent(eventTree); internalEvent = event_getChild(rootEvent, 0); leafEvent1 = event_getChild(internalEvent, 0); leafEvent2 = event_getChild(internalEvent, 1); free(vA); nestedTest = 1; testEventTree_copyConstruct(testCase); testEventTree_getRootEvent(testCase); testEventTree_getEvent(testCase); testEventTree_getCommonAncestor(testCase); testEventTree_getFlower(testCase); testEventTree_getEventNumber(testCase); testEventTree_getFirst(testCase); testEventTree_makeNewickString(testCase); testEventTree_iterator(testCase); testEventTree_addSiblingUnaryEvent(testCase); nestedTest = 0; cactusEventTreeTestTeardown(); }