diff --git a/salaTest/testshaperemove.cpp b/salaTest/testshaperemove.cpp index 9e066688..437cc9a6 100644 --- a/salaTest/testshaperemove.cpp +++ b/salaTest/testshaperemove.cpp @@ -308,6 +308,25 @@ TEST_CASE("Testing deleting shapes from segment maps") { segmentMap->removeShape(shapeRef, false); REQUIRE(segmentMap->getAllShapes().size() == idx - 1); REQUIRE(segmentMap->getConnections().size() == idx - 1); + + for (auto it = segmentMap->getAllShapes().begin(); it != segmentMap->getAllShapes().end(); it++) { + std::vector connForConnections = segmentForConnections[it->first]; + std::vector connBackConnections = segmentBackConnections[it->first]; + if (std::find(connForConnections.begin(), connForConnections.end(), shapeRef) != + connForConnections.end()) { + // if the other shape contains this one, then remove from its connectivity + // removal does not currently work for segment maps, so connectivity is not adjusted + connectivitiesAfterRemoval[it->first] = connectivitiesAfterRemoval[it->first] - 1; + } else if (std::find(connBackConnections.begin(), connBackConnections.end(), shapeRef) != + connBackConnections.end()) { + // if the other shape contains this one, then remove from its connectivity + // removal does not currently work for segment maps, so connectivity is not adjusted + connectivitiesAfterRemoval[it->first] = connectivitiesAfterRemoval[it->first] - 1; + } + + REQUIRE(segmentTable.getRow(AttributeKey(it->first)).getValue(segmentConnectivityColIdx) == + connectivitiesAfterRemoval[it->first]); + } } } @@ -325,6 +344,25 @@ TEST_CASE("Testing deleting shapes from segment maps") { segmentMap->removeShape(shapeRef, false); REQUIRE(segmentMap->getAllShapes().size() == idx - 1); REQUIRE(segmentMap->getConnections().size() == idx - 1); + + for (auto it = segmentMap->getAllShapes().begin(); it != segmentMap->getAllShapes().end(); it++) { + std::vector connForConnections = segmentForConnections[it->first]; + std::vector connBackConnections = segmentBackConnections[it->first]; + if (std::find(connForConnections.begin(), connForConnections.end(), shapeRef) != + connForConnections.end()) { + // if the other shape contains this one, then remove from its connectivity + // removal does not currently work for segment maps, so connectivity is not adjusted + connectivitiesAfterRemoval[it->first] = connectivitiesAfterRemoval[it->first] - 1; + } else if (std::find(connBackConnections.begin(), connBackConnections.end(), shapeRef) != + connBackConnections.end()) { + // if the other shape contains this one, then remove from its connectivity + // removal does not currently work for segment maps, so connectivity is not adjusted + connectivitiesAfterRemoval[it->first] = connectivitiesAfterRemoval[it->first] - 1; + } + + REQUIRE(segmentTable.getRow(AttributeKey(it->first)).getValue(segmentConnectivityColIdx) == + connectivitiesAfterRemoval[it->first]); + } } } @@ -344,6 +382,25 @@ TEST_CASE("Testing deleting shapes from segment maps") { segmentMap->removeShape(shapeRef, false); REQUIRE(segmentMap->getAllShapes().size() == idx - 1); REQUIRE(segmentMap->getConnections().size() == idx - 1); + + for (auto it = segmentMap->getAllShapes().begin(); it != segmentMap->getAllShapes().end(); it++) { + std::vector connForConnections = segmentForConnections[it->first]; + std::vector connBackConnections = segmentBackConnections[it->first]; + if (std::find(connForConnections.begin(), connForConnections.end(), shapeRef) != + connForConnections.end()) { + // if the other shape contains this one, then remove from its connectivity + // removal does not currently work for segment maps, so connectivity is not adjusted + connectivitiesAfterRemoval[it->first] = connectivitiesAfterRemoval[it->first] - 1; + } else if (std::find(connBackConnections.begin(), connBackConnections.end(), shapeRef) != + connBackConnections.end()) { + // if the other shape contains this one, then remove from its connectivity + // removal does not currently work for segment maps, so connectivity is not adjusted + connectivitiesAfterRemoval[it->first] = connectivitiesAfterRemoval[it->first] - 1; + } + + REQUIRE(segmentTable.getRow(AttributeKey(it->first)).getValue(segmentConnectivityColIdx) == + connectivitiesAfterRemoval[it->first]); + } } } }