Constructs simple fake graph where vertex (i + 1) is child of vertex (i) with |numFake| fake vertices and |numReal| real vertices. Checks vertex-to-segment, segment-to-vertex, fake-to-real, real-to-fake mappings for each vertex. Checks ingoing and outgoing sets.
| 38 | // vertices and |numReal| real vertices. Checks vertex-to-segment, segment-to-vertex, fake-to-real, |
| 39 | // real-to-fake mappings for each vertex. Checks ingoing and outgoing sets. |
| 40 | FakeGraph ConstructFakeGraph(uint32_t numerationStart, uint32_t numFake, uint32_t numReal) |
| 41 | { |
| 42 | FakeGraph fakeGraph; |
| 43 | TEST_EQUAL(fakeGraph.GetSize(), 0, ("Constructed fake graph not empty")); |
| 44 | if (numFake < 1) |
| 45 | { |
| 46 | CHECK_EQUAL(numReal, 0, ("Construction of non-empty fake graph without pure fake vertices not supported.")); |
| 47 | return fakeGraph; |
| 48 | } |
| 49 | |
| 50 | auto const startSegment = GetSegment(numerationStart); |
| 51 | auto const startVertex = GetFakeVertex(numerationStart); |
| 52 | fakeGraph.AddStandaloneVertex(startSegment, startVertex); |
| 53 | |
| 54 | // Add pure fake. |
| 55 | for (uint32_t prevNumber = numerationStart; prevNumber + 1 < numerationStart + numFake + numReal; ++prevNumber) |
| 56 | { |
| 57 | bool const newIsReal = prevNumber + 1 >= numerationStart + numFake; |
| 58 | auto const prevSegment = GetSegment(prevNumber); |
| 59 | auto const newSegment = GetSegment(prevNumber + 1); |
| 60 | auto const newVertex = GetFakeVertex(prevNumber + 1); |
| 61 | auto const realSegment = GetSegment(prevNumber + 1, true /* isReal */); |
| 62 | |
| 63 | fakeGraph.AddVertex(prevSegment, newSegment, newVertex, true /* isOutgoing */, newIsReal /* isPartOfReal */, |
| 64 | realSegment); |
| 65 | |
| 66 | // Test segment to vertex mapping. |
| 67 | TEST_EQUAL(fakeGraph.GetVertex(newSegment), newVertex, ("Wrong segment to vertex mapping.")); |
| 68 | // Test outgoing edge. |
| 69 | TEST_EQUAL(fakeGraph.GetEdges(newSegment, false /* isOutgoing */), set<Segment>{prevSegment}, |
| 70 | ("Wrong ingoing edges set.")); |
| 71 | // Test ingoing edge. |
| 72 | TEST_EQUAL(fakeGraph.GetEdges(prevSegment, true /* isOutgoing */), set<Segment>{newSegment}, |
| 73 | ("Wrong ingoing edges set.")); |
| 74 | // Test graph size |
| 75 | TEST_EQUAL(fakeGraph.GetSize() + numerationStart, prevNumber + 2, ("Wrong fake graph size.")); |
| 76 | // Test fake to real and real to fake mapping. |
| 77 | Segment realFound; |
| 78 | if (newIsReal) |
| 79 | { |
| 80 | TEST_EQUAL(fakeGraph.FindReal(newSegment, realFound), true, ("Unexpected real segment found.")); |
| 81 | TEST_EQUAL(realSegment, realFound, ("Wrong fake to real mapping.")); |
| 82 | TEST_EQUAL(fakeGraph.GetFake(realSegment), set<Segment>{newSegment}, ("Unexpected fake segment found.")); |
| 83 | } |
| 84 | else |
| 85 | { |
| 86 | TEST_EQUAL(fakeGraph.FindReal(newSegment, realFound), false, ("Unexpected real segment found.")); |
| 87 | TEST(fakeGraph.GetFake(realSegment).empty(), ("Unexpected fake segment found.")); |
| 88 | } |
| 89 | } |
| 90 | return fakeGraph; |
| 91 | } |
| 92 | |
| 93 | // Test constructs two fake graphs, performs checks during construction, merges graphs |
| 94 | // Calls FakeGraph::Append and checks topology of the merged graph. |
no test coverage detected