[yul-phaser] Chromosome: store step abbreviations instead of full names

This commit is contained in:
Kamil Śliwak
2020-09-11 22:05:56 +02:00
parent 2a707e7685
commit 952a9c6115
5 changed files with 48 additions and 66 deletions
+3 -12
View File
@@ -24,6 +24,7 @@
#include <libsolutil/CommonIO.h>
#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <algorithm>
#include <vector>
@@ -117,12 +118,7 @@ BOOST_AUTO_TEST_CASE(geneAddition_should_be_able_to_insert_before_first_position
Chromosome mutatedChromosome = mutation(chromosome);
BOOST_TEST(mutatedChromosome.length() > chromosome.length());
vector<string> suffix(
mutatedChromosome.optimisationSteps().end() - static_cast<ptrdiff_t>(chromosome.length()),
mutatedChromosome.optimisationSteps().end()
);
BOOST_TEST(suffix == chromosome.optimisationSteps());
BOOST_TEST(boost::ends_with(mutatedChromosome.genes(), chromosome.genes()));
}
BOOST_AUTO_TEST_CASE(geneAddition_should_be_able_to_insert_after_last_position)
@@ -133,12 +129,7 @@ BOOST_AUTO_TEST_CASE(geneAddition_should_be_able_to_insert_after_last_position)
Chromosome mutatedChromosome = mutation(chromosome);
BOOST_TEST(mutatedChromosome.length() > chromosome.length());
vector<string> prefix(
mutatedChromosome.optimisationSteps().begin(),
mutatedChromosome.optimisationSteps().begin() + static_cast<ptrdiff_t>(chromosome.length())
);
BOOST_TEST(prefix == chromosome.optimisationSteps());
BOOST_TEST(boost::starts_with(mutatedChromosome.genes(), chromosome.genes()));
}
BOOST_AUTO_TEST_CASE(geneAddition_should_return_identical_chromosome_if_probability_is_zero)