Add tests for Chromosome and Generation.
[genetic.git] / tests / chromosome / create.cpp
1 #include <iostream>
2 #include <vector>
3
4 #include "gene.h"
5 #include "chromosome.h"
6
7 using namespace std;
8 using namespace genetic;
9
10 int main() {
11     typedef Gene<int> _Gene;
12     typedef Chromosome<_Gene> _Chromosome;
13
14     const unsigned int chromosomeSize = 20;
15
16     std::vector<_Gene> data;
17
18     for (unsigned int i = 0; i < chromosomeSize; i++) {
19         data.push_back(_Gene(i));
20     }
21
22     _Chromosome chromosome(data);
23
24     if (chromosome.size() != chromosomeSize) {
25         cout << "Chromosome contained incorrect size after creation\n";
26         return 1;
27     }
28
29     for (unsigned int i = 0; i < chromosome.size(); i++) {
30         if (chromosome[i].get() != i) {
31             cout << "Chromosome contained bad data after creation\n";
32             return 1;
33         }
34     }
35
36     cout << "Chromosome is created correctly\n";
37     return 0;
38 }
39