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 testBlock_serialisation(CuTest* testCase) { cactusBlockTestSetup(); Name rootInstanceName = segment_getName(rootSegment); Name leaf1InstanceName = segment_getName(leaf1Segment); Name leaf2InstanceName = segment_getName(leaf2Segment); int64_t i; void *vA = binaryRepresentation_makeBinaryRepresentation(block, (void(*)(void *, void(*)(const void *, size_t, size_t))) block_writeBinaryRepresentation, &i); CuAssertTrue(testCase, i > 0); block_destruct(block); void *vA2 = vA; block = block_loadFromBinaryRepresentation(&vA2, flower); rootSegment = segment_getReverse(block_getInstance(block, rootInstanceName)); leaf1Segment = block_getInstance(block, leaf1InstanceName); leaf2Segment = segment_getReverse(block_getInstance(block, leaf2InstanceName)); free(vA); nestedTest = 1; testBlock_getName(testCase); testBlock_getOrientation(testCase); testBlock_getReverse(testCase); testBlock_getLength(testCase); testBlock_getFlower(testCase); testBlock_getLeftEnd(testCase); testBlock_getRightEnd(testCase); testBlock_getSetRootInstance(testCase); testBlock_getInstanceNumber(testCase); testBlock_getInstance(testCase); testBlock_getFirst(testCase); testBlock_instanceIterator(testCase); testBlock_makeNewickString(testCase); testBlock_getChain(testCase); testBlock_getSegmentForEvent(testCase); nestedTest = 0; cactusBlockTestTeardown(); }