示例#1
0
void testGroup_serialisation(CuTest* testCase) {
    cactusGroupTestSetup();
    int64_t i;
    Name name = group_getName(group);
    void
            *vA =
                    binaryRepresentation_makeBinaryRepresentation(group,
                            (void(*)(void *, void(*)(const void *, size_t,
                                    size_t))) group_writeBinaryRepresentation,
                            &i);
    CuAssertTrue(testCase, i > 0);
    group_destruct(group);
    void *vA2 = vA;
    group = group_loadFromBinaryRepresentation(&vA2, flower);
    free(vA);
    CuAssertTrue(testCase, group_getName(group) == name);
    CuAssertTrue(testCase, group_getFlower(group) == flower);
    CuAssertTrue(testCase, group_getNestedFlower(group) == nestedFlower);
    Group_EndIterator *iterator = group_getEndIterator(group);
    CuAssertTrue(testCase, group_getNextEnd(iterator) == end1);
    CuAssertTrue(testCase, group_getNextEnd(iterator) == end2);
    CuAssertTrue(testCase, group_getNextEnd(iterator) == NULL);
    group_destructEndIterator(iterator);

    cactusGroupTestTeardown();
}
示例#2
0
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;
}