| 344 | } |
| 345 | |
| 346 | void fuzzyMatchSymbol(const Map& map, const QByteArray& format_id, const Symbol* expected) |
| 347 | { |
| 348 | Symbol const* actual = nullptr; |
| 349 | for (auto i = 0; !actual && i < map.getNumSymbols(); ++i) |
| 350 | { |
| 351 | auto const* symbol = map.getSymbol(i); |
| 352 | if (symbol->getType() != expected->getType() |
| 353 | && symbol->getType() != Symbol::Combined) |
| 354 | { |
| 355 | continue; |
| 356 | } |
| 357 | |
| 358 | if (format_id.startsWith("OCD")) |
| 359 | { |
| 360 | // In OCD format, export may have incremented second and or first component. |
| 361 | if (symbol->getNumberComponent(0) < expected->getNumberComponent(0) |
| 362 | || symbol->getNumberComponent(0) > expected->getNumberComponent(0) + 1) |
| 363 | { |
| 364 | continue; |
| 365 | } |
| 366 | } |
| 367 | else if (expected->getNumberAsString() != symbol->getNumberAsString()) |
| 368 | { |
| 369 | continue; |
| 370 | } |
| 371 | |
| 372 | if (!expected->getPlainTextName().startsWith(symbol->getPlainTextName())) |
| 373 | continue; |
| 374 | |
| 375 | actual = symbol; |
| 376 | } |
| 377 | if (format_id == "OCD8") |
| 378 | { |
| 379 | // Don't elaborate testing for these legacy formats. |
| 380 | switch (expected->getType()) |
| 381 | { |
| 382 | case Symbol::Combined: |
| 383 | // Expected symbol may be entirely dropped. (Its parts live independently.) |
| 384 | if (!actual) |
| 385 | return; |
| 386 | break; |
| 387 | case Symbol::Line: |
| 388 | // Expected symbol may be entirely turned into combined symbol. |
| 389 | break; |
| 390 | default: |
| 391 | ; // nothing |
| 392 | } |
| 393 | } |
| 394 | if (actual) |
| 395 | fuzzyCompareSymbol(*actual, *expected, format_id); |
| 396 | else |
| 397 | QFAIL(qPrintable(QString::fromLatin1("Missing symbol: %1 %2").arg(expected->getNumberAsString(), expected->getPlainTextName()))); |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * Compares map features in a way that works for lossy exporters and importers. |
no test coverage detected