| 613 | } |
| 614 | |
| 615 | bool compareGenomeColorMutation(std::vector<uint8_t> const& before, std::vector<uint8_t> const& after, std::optional<int> const& allowedColor) |
| 616 | { |
| 617 | auto beforeGenome = GenomeDescriptionService::get().convertBytesToDescription(before); |
| 618 | auto afterGenome = GenomeDescriptionService::get().convertBytesToDescription(after); |
| 619 | if (afterGenome.header != beforeGenome.header) { |
| 620 | return false; |
| 621 | } |
| 622 | |
| 623 | int uniformColor = allowedColor ? *allowedColor : afterGenome.cells.at(0).color; |
| 624 | for (auto const& [beforeCell, afterCell] : boost::combine(beforeGenome.cells, afterGenome.cells)) { |
| 625 | |
| 626 | auto beforeCellClone = beforeCell; |
| 627 | auto afterCellClone = afterCell; |
| 628 | beforeCellClone.color = 0; |
| 629 | beforeCellClone.cellFunction = std::nullopt; |
| 630 | afterCellClone.color = 0; |
| 631 | afterCellClone.cellFunction = std::nullopt; |
| 632 | if (beforeCellClone != afterCellClone) { |
| 633 | return false; |
| 634 | } |
| 635 | if (afterCell.color != uniformColor) { |
| 636 | return false; |
| 637 | } |
| 638 | uniformColor = afterCell.color; |
| 639 | if (beforeCell.getCellFunctionType() == CellFunction_Constructor || beforeCell.getCellFunctionType() == CellFunction_Injector) { |
| 640 | auto beforeSubGenome = beforeCell.getGenome(); |
| 641 | auto afterSubGenome = afterCell.getGenome(); |
| 642 | if (beforeSubGenome && afterSubGenome) { |
| 643 | if (!compareGenomeColorMutation(*beforeSubGenome, *afterSubGenome, uniformColor)) { |
| 644 | return false; |
| 645 | } |
| 646 | } |
| 647 | } |
| 648 | } |
| 649 | return true; |
| 650 | } |
| 651 | }; |
| 652 | |
| 653 | TEST_F(MutationTests, propertiesMutation) |
nothing calls this directly
no test coverage detected