Exemple #1
0
void testFlower_builtTrees(CuTest *testCase) {
    cactusFlowerTestSetup();

    CuAssertTrue(testCase, !flower_builtTrees(flower));
    flower_setBuiltTrees(flower, 0);
    CuAssertTrue(testCase, !flower_builtTrees(flower));
    flower_setBuiltTrees(flower, 1);
    CuAssertTrue(testCase, flower_builtTrees(flower));
    flower_setBuiltTrees(flower, 0);
    CuAssertTrue(testCase, !flower_builtTrees(flower));

    cactusFlowerTestTeardown();
}
Exemple #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;
}
Exemple #3
0
void flower_makeTerminalNormal(Flower *flower) {
    if (!flower_isTerminal(flower)) {
        Flower_GroupIterator *groupIterator;
        Group *group;
        groupIterator = flower_getGroupIterator(flower);
        while ((group = flower_getNextGroup(groupIterator)) != NULL) {
            if (group_isLeaf(group)) {
                //assert(group_getTotalBaseLength(group) == 0);
                Flower *nestedFlower = group_makeNestedFlower(group);
                flower_setBuiltBlocks(nestedFlower, flower_builtBlocks(flower));
                flower_setBuiltTrees(nestedFlower, flower_builtTrees(flower));
                flower_setBuildFaces(nestedFlower, flower_builtFaces(flower));
            }
        }
        flower_destructGroupIterator(groupIterator);
    }
}