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 testEnd_serialisation(CuTest* testCase) { cactusEndTestSetup(); Name rootInstanceName = cap_getName(rootCap); Name leaf1InstanceName = cap_getName(leaf1Cap); Name leaf2InstanceName = cap_getName(leaf2Cap); Name leaf3InstanceName = cap_getName(leaf3Cap); int64_t i; void *vA = binaryRepresentation_makeBinaryRepresentation(end, (void(*)(void *, void(*)(const void *, size_t, size_t))) end_writeBinaryRepresentation, &i); CuAssertTrue(testCase, i > 0); end_destruct(end); void *vA2 = vA; end = end_loadFromBinaryRepresentation(&vA2, flower); rootCap = cap_getReverse(end_getInstance(end, rootInstanceName)); leaf1Cap = cap_getReverse(end_getInstance(end, leaf1InstanceName)); leaf2Cap = end_getInstance(end, leaf2InstanceName); leaf3Cap = cap_getReverse(end_getInstance(end, leaf3InstanceName)); CuAssertTrue(testCase, leaf3Cap != NULL); free(vA); nestedTest = 1; testEnd_copyConstruct(testCase); testEnd_getName(testCase); testEnd_getOrientation(testCase); testEnd_getReverse(testCase); testEnd_getSide(testCase); testEnd_getFlower(testCase); testEnd_getBlock(testCase); testEnd_getOtherBlockEnd(testCase); testEnd_getGroup(testCase); testEnd_setGroup(testCase); testEnd_getInstanceNumber(testCase); testEnd_getInstance(testCase); testEnd_getFirst(testCase); testEnd_getSetRootInstance(testCase); testEnd_instanceIterator(testCase); testEnd_isBlockOrStubEnd(testCase); testEnd_isAttachedOrFree(testCase); testEnd_getCapForEvent(testCase); nestedTest = 0; cactusEndTestTeardown(); }