Esempio n. 1
0
void testGroup_getAttachedStubAndBlockEndNumber(CuTest* testCase) {
    cactusGroupTestSetup();
    CuAssertTrue(testCase, group_getAttachedStubEndNumber(group) == 0);
    CuAssertTrue(testCase, group_getBlockEndNumber(group) == 0);
    CuAssertIntEquals(testCase, 2, group_getStubEndNumber(group));
    CuAssertIntEquals(testCase, 2, group_getFreeStubEndNumber(group));
    end_setGroup(end_construct(1, flower), group);
    end_setGroup(end_construct(0, flower), group);
    end_setGroup(end_construct(1, flower), group);
    CuAssertTrue(testCase, group_getAttachedStubEndNumber(group) == 2);
    CuAssertTrue(testCase, group_getBlockEndNumber(group) == 0);
    CuAssertTrue(testCase, group_getStubEndNumber(group) == 5);
    CuAssertTrue(testCase, group_getFreeStubEndNumber(group) == 3);
    Block *block = block_construct(1, flower);
    end_setGroup(block_get5End(block), group);
    end_setGroup(block_get3End(block), group);
    CuAssertTrue(testCase, group_getAttachedStubEndNumber(group) == 2);
    CuAssertTrue(testCase, group_getBlockEndNumber(group) == 2);
    CuAssertTrue(testCase, group_getStubEndNumber(group) == 5);
    CuAssertTrue(testCase, group_getFreeStubEndNumber(group) == 3);
    cactusGroupTestTeardown();
}
Esempio n. 2
0
void flower_checkNotEmpty(Flower *flower, bool recursive) {
    //First check the flower is not empty, unless it is the parent group.
    if (flower_hasParentGroup(flower)) {
        assert(flower_getGroupNumber(flower) > 0);
        assert(flower_getEndNumber(flower) > 0);
        assert(flower_getAttachedStubEndNumber(flower) > 0); //We must have some ends to tie us into the parent problem + flower_getBlockEndNumber(flower) > 0);
    }
    //Now Checks that each group contains at least one end and call recursive.
    Group *group;
    Flower_GroupIterator *groupIt = flower_getGroupIterator(flower);
    while ((group = flower_getNextGroup(groupIt)) != NULL) {
        assert(group_getEndNumber(group) > 0);
        assert(group_getAttachedStubEndNumber(group) + group_getBlockEndNumber(group) > 0);
        if (recursive && !group_isLeaf(group)) {
            flower_checkNotEmpty(group_getNestedFlower(group), 1);
        }
    }
    flower_destructGroupIterator(groupIt);
}