def test_fitness(): assert(bitarray_chromosome([0, 0, 0, 0, 0, 0, 0, 0]).fitness() == 8) assert(bitarray_chromosome([0, 0, 0, 0, 0, 0, 0, 1]).fitness() == 7) assert(bitarray_chromosome([0, 0, 0, 0, 0, 0, 1, 1]).fitness() == 6) assert(bitarray_chromosome([0, 0, 0, 0, 0, 1, 1, 1]).fitness() == 5) assert(bitarray_chromosome([0, 0, 0, 1, 1, 1, 1, 0]).fitness() == 4) assert(bitarray_chromosome([1, 1, 1, 1, 1, 0, 0, 0]).fitness() == 3) assert(bitarray_chromosome([0, 0, 1, 1, 1, 1, 1, 1]).fitness() == 2) assert(bitarray_chromosome([1, 1, 1, 1, 1, 0, 1, 1]).fitness() == 1) assert(bitarray_chromosome([1, 1, 1, 1, 1, 1, 1, 1]).fitness() == 0)
def test_initialiser_too_long(): g = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] c = bitarray_chromosome(g) assert(c.genome == [1, 1, 1, 1, 1, 1, 1, 1])
def test_initialiser_correct_length(): g = [1, 1, 1, 1, 1, 1, 1, 1] c = bitarray_chromosome(g) assert(c.genome == g)
def test_initialiser_too_short(): g = [1, 1, 1, 1, 1, 1] c = bitarray_chromosome(g) assert(c.genome == [1, 1, 1, 1, 1, 1, 0, 0])