| 178 | |
| 179 | |
| 180 | void PathObjectTest::constructorTest() |
| 181 | { |
| 182 | // PathObject(const Symbol* symbol = nullptr) |
| 183 | |
| 184 | PathObject no_symbol{}; |
| 185 | QCOMPARE(no_symbol.getMap(), static_cast<Map*>(nullptr)); |
| 186 | QCOMPARE(no_symbol.getSymbol(), static_cast<Symbol*>(nullptr)); |
| 187 | QVERIFY(no_symbol.getRawCoordinateVector().empty()); |
| 188 | QVERIFY(no_symbol.parts().empty()); |
| 189 | QCOMPARE(no_symbol.getPatternOrigin(), MapCoord()); |
| 190 | QCOMPARE(no_symbol.getPatternRotation(), qreal(0)); |
| 191 | |
| 192 | { |
| 193 | PathObject no_symbol_2{nullptr}; |
| 194 | QVERIFY(no_symbol_2.equals(&no_symbol, true)); |
| 195 | } |
| 196 | |
| 197 | PathObject empty_red{Map::getCoveringRedLine()}; |
| 198 | QCOMPARE(empty_red.getMap(), static_cast<Map*>(nullptr)); |
| 199 | QCOMPARE(empty_red.getSymbol(), Map::getCoveringRedLine()); |
| 200 | QVERIFY(empty_red.getRawCoordinateVector().empty()); |
| 201 | QVERIFY(empty_red.parts().empty()); |
| 202 | QCOMPARE(empty_red.getPatternOrigin(), MapCoord()); |
| 203 | QCOMPARE(empty_red.getPatternRotation(), qreal(0)); |
| 204 | QVERIFY(empty_red.equals(&no_symbol, false)); |
| 205 | QVERIFY(!empty_red.equals(&no_symbol, true)); |
| 206 | |
| 207 | // PathObject(const Symbol* symbol, const MapCoordVector& coords, Map* map = nullptr) |
| 208 | |
| 209 | Map map; |
| 210 | auto coords = MapCoordVector{ |
| 211 | MapCoord{0.0, 0.0}, MapCoord{0.0, 5.0}, MapCoord{5.0, 0.0}, MapCoord{0.0, 0.0, MapCoord::ClosePoint|MapCoord::HolePoint}, |
| 212 | MapCoord{1.0, 1.0}, MapCoord{0.0, 3.0}, MapCoord{3.0, 0.0}, MapCoord{1.0, 1.0, MapCoord::ClosePoint|MapCoord::HolePoint} |
| 213 | }; |
| 214 | PathObject red_area{Map::getCoveringRedLine(), coords, &map}; |
| 215 | QCOMPARE(red_area.getMap(), &map); |
| 216 | QCOMPARE(red_area.getSymbol(), Map::getCoveringRedLine()); |
| 217 | QCOMPARE(red_area.getRawCoordinateVector(), coords); |
| 218 | QCOMPARE(red_area.parts().size(), std::size_t(2)); |
| 219 | QCOMPARE(red_area.getPatternOrigin(), MapCoord()); |
| 220 | QCOMPARE(red_area.getPatternRotation(), qreal(0)); |
| 221 | |
| 222 | { |
| 223 | PathObject other_area{Map::getCoveringWhiteLine(), coords}; |
| 224 | QVERIFY(other_area.getMap() != red_area.getMap()); // not tested by `equals` |
| 225 | QVERIFY(other_area.equals(&red_area, false)); |
| 226 | QVERIFY(!other_area.equals(&red_area, true)); |
| 227 | |
| 228 | other_area.setSymbol(red_area.getSymbol(), true); |
| 229 | QVERIFY(other_area.equals(&red_area, false)); |
| 230 | QVERIFY(other_area.equals(&red_area, true)); |
| 231 | |
| 232 | other_area.setPatternOrigin({1.0, 1.0}); |
| 233 | QVERIFY(!other_area.equals(&red_area, false)); |
| 234 | QVERIFY(!other_area.equals(&red_area, true)); |
| 235 | |
| 236 | other_area.setPatternOrigin(red_area.getPatternOrigin()); |
| 237 | other_area.setPatternRotation(1.0); |
nothing calls this directly
no test coverage detected