static void facesSetup() { face = face_construct(flower); face2 = face_construct(flower); if (flower_getFirstFace(flower) == face2) { //switch round, because we have no guarantted order for faces.. Face *face3 = face2; face2 = face; face = face3; } }
void testCap_getTopFace(CuTest* testCase) { cactusCapTestSetup(); Face *face = face_construct(flower); cap_setTopFace(rootCap, face); CuAssertTrue(testCase, cap_getTopFace(rootCap) == face); CuAssertTrue(testCase, cap_getTopFace(cap_getReverse(rootCap)) == face); cactusCapTestTeardown(); }
/* * Constructs a face from a given Cap */ static void buildFaces_constructFromCap(Cap * startingCap, stHash *liftedEdgesTable, Flower * flower) { Face *face = face_construct(flower); stList *topNodes = stList_construct3(16, NULL); stList *liftedEdges; Cap *cap, *bottomNode, *ancestor; int64_t index, index2; printf("Constructing new face"); // Establishlist of top nodes buildFaces_fillTopNodeList(startingCap, topNodes, liftedEdgesTable); #ifndef NDEBUG // What, no top nodes!? if (stList_length(topNodes) == 0) abort(); #endif // Initialize data structure face_allocateSpace(face, stList_length(topNodes)); // For every top node for (index = 0; index < stList_length(topNodes); index++) { cap = stList_get(topNodes, index); face_setTopNode(face, index, cap); liftedEdges = stHash_search(liftedEdgesTable, cap); if (!liftedEdges) { face_setBottomNodeNumber(face, index, 0); continue; } face_setBottomNodeNumber(face, index, stList_length(liftedEdges)); // For every bottom node of that top node for (index2 = 0; index2 < stList_length(liftedEdges); index2++) { bottomNode = ((LiftedEdge *) stList_get(liftedEdges, index2))->bottomNode; face_addBottomNode(face, index, bottomNode); ancestor = cap_getTopCap(cap_getPositiveOrientation( cap_getAdjacency(bottomNode))); if (cap_getAdjacency(cap) != ancestor) face_setDerivedDestination(face, index, index2, ancestor); else face_setDerivedDestination(face, index, index2, NULL); #ifndef NDEBUG // If bottom nodes part of top nodes assert(!stList_contains(topNodes, cap_getPositiveOrientation( ((LiftedEdge*) stList_get(liftedEdges, index2))->bottomNode))); #endif } } // Clean up stList_destruct(topNodes); }
void testCap_getBottomAndTopFaceEnd(CuTest* testCase) { cactusCapTestSetup(); End *end1 = end_construct(0, flower); Cap *cap1T = cap_construct(end1, rootEvent); Cap *cap1L = cap_construct(end1, leafEvent); cap_makeParentAndChild(cap1T, cap1L); end_setRootInstance(end1, cap1T); End *end2 = end_construct(0, flower); Cap *cap2T = cap_construct(end2, rootEvent); Cap *cap2L = cap_construct(end2, leafEvent); cap_makeParentAndChild(cap2T, cap2L); end_setRootInstance(end2, cap2T); CuAssertTrue(testCase, cap_getBottomFaceEnd(cap1T) == NULL); CuAssertTrue(testCase, cap_getBottomFaceEnd(cap1L) == NULL); CuAssertTrue(testCase, cap_getTopFaceEnd(cap1T) == NULL); CuAssertTrue(testCase, cap_getTopFaceEnd(cap1L) == NULL); cap_makeAdjacent(cap1L, cap2L); cap_makeAdjacent(cap1T, cap2T); //Now make the face Face *face = face_construct(flower); face_allocateSpace(face, 2); face_setTopNode(face, 0, cap1T); face_setTopNode(face, 1, cap2T); face_setBottomNodeNumber(face, 0, 1); face_setBottomNodeNumber(face, 1, 1); face_addBottomNode(face, 0, cap1L); face_addBottomNode(face, 1, cap2L); CuAssertTrue(testCase, cap_getTopFaceEnd(cap1L) == NULL); CuAssertTrue(testCase, cap_getTopFaceEnd(cap2L) == NULL); FaceEnd *faceEnd1 = cap_getTopFaceEnd(cap1T); FaceEnd *faceEnd2 = cap_getTopFaceEnd(cap2T); CuAssertTrue(testCase, faceEnd_getTopNode(faceEnd1) == cap1T); CuAssertTrue(testCase, faceEnd_getTopNode(faceEnd2) == cap2T); CuAssertTrue(testCase, cap_getBottomFaceEnd(cap1T) == NULL); CuAssertTrue(testCase, cap_getBottomFaceEnd(cap2T) == NULL); CuAssertTrue(testCase, cap_getBottomFaceEnd(cap1L) == faceEnd1); CuAssertTrue(testCase, cap_getBottomFaceEnd(cap2L) == faceEnd2); cactusCapTestTeardown(); }