diff --git a/test/yulPhaser/Mutations.cpp b/test/yulPhaser/Mutations.cpp index 86e9992f9..b20cb8e4c 100644 --- a/test/yulPhaser/Mutations.cpp +++ b/test/yulPhaser/Mutations.cpp @@ -179,8 +179,8 @@ BOOST_AUTO_TEST_CASE(alternativeMutations_should_choose_between_mutations_with_g for (size_t i = 0; i < 10; ++i) { Chromosome mutatedChromosome = mutation(chromosome); - cCount += static_cast(mutatedChromosome == Chromosome("c")); - fCount += static_cast(mutatedChromosome == Chromosome("f")); + cCount += (mutatedChromosome == Chromosome("c") ? 1 : 0); + fCount += (mutatedChromosome == Chromosome("f") ? 1 : 0); } // This particular seed results in 7 "c"s out of 10 which looks plausible given the 80% chance. diff --git a/test/yulPhaser/Population.cpp b/test/yulPhaser/Population.cpp index 1657e97c9..5fd8c2073 100644 --- a/test/yulPhaser/Population.cpp +++ b/test/yulPhaser/Population.cpp @@ -135,7 +135,7 @@ BOOST_FIXTURE_TEST_CASE(makeRandom_should_get_chromosome_lengths_from_specified_ size_t maxLength = 5; assert(chromosomeCount % maxLength == 0); - auto nextLength = [counter = 0, maxLength]() mutable { return counter++ % maxLength; }; + auto nextLength = [counter = 0ul, maxLength]() mutable { return counter++ % maxLength; }; auto population = Population::makeRandom(m_fitnessMetric, chromosomeCount, nextLength); // We can't rely on the order since the population sorts its chromosomes immediately but diff --git a/test/yulPhaser/TestHelpers.cpp b/test/yulPhaser/TestHelpers.cpp index 2379016fe..2f4b40b02 100644 --- a/test/yulPhaser/TestHelpers.cpp +++ b/test/yulPhaser/TestHelpers.cpp @@ -72,9 +72,13 @@ size_t phaser::test::countDifferences(Chromosome const& _chromosome1, Chromosome { size_t count = 0; for (size_t i = 0; i < min(_chromosome1.length(), _chromosome2.length()); ++i) - count += static_cast(_chromosome1.optimisationSteps()[i] != _chromosome2.optimisationSteps()[i]); + if (_chromosome1.optimisationSteps()[i] != _chromosome2.optimisationSteps()[i]) + ++count; - return count + abs(static_cast(_chromosome1.length() - _chromosome2.length())); + return count + static_cast(abs( + static_cast(_chromosome1.length()) - + static_cast(_chromosome2.length()) + )); } TemporaryDirectory::TemporaryDirectory(std::string const& _prefix):