diff options
| author | Mike Buland <mike@xagasoft.com> | 2012-08-05 01:27:43 -0600 |
|---|---|---|
| committer | Mike Buland <mike@xagasoft.com> | 2012-08-05 01:27:43 -0600 |
| commit | e9cfcc6dfc8427904ab227eea2452ccddd8f295c (patch) | |
| tree | 197c9fbd24e0e63d2f4c3ddb0dbf136c44bebb7e /src/tests | |
| parent | 8a0d33b5ebb3497d158f2d5c050c69be3fcd1e0d (diff) | |
| download | libgenetic-e9cfcc6dfc8427904ab227eea2452ccddd8f295c.tar.gz libgenetic-e9cfcc6dfc8427904ab227eea2452ccddd8f295c.tar.bz2 libgenetic-e9cfcc6dfc8427904ab227eea2452ccddd8f295c.tar.xz libgenetic-e9cfcc6dfc8427904ab227eea2452ccddd8f295c.zip | |
Added I/O test for binary phenotypes.
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/io.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/tests/io.cpp b/src/tests/io.cpp new file mode 100644 index 0000000..871a813 --- /dev/null +++ b/src/tests/io.cpp | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | #include "genetic/phenotypebinary.h" | ||
| 2 | #include "genetic/operatorbasic.h" | ||
| 3 | |||
| 4 | #include <bu/sio.h> | ||
| 5 | #include <bu/membuf.h> | ||
| 6 | #include <bu/random.h> | ||
| 7 | #include <bu/randomcmwc.h> | ||
| 8 | #include <bu/randomsystem.h> | ||
| 9 | #include <time.h> | ||
| 10 | |||
| 11 | using namespace Bu; | ||
| 12 | |||
| 13 | int main( int argc, char *argv[] ) | ||
| 14 | { | ||
| 15 | Bu::Random::setGenerator<Bu::RandomCmwc>(); | ||
| 16 | Bu::Random::seed( time( NULL ) ); | ||
| 17 | |||
| 18 | Genetic::OperatorBasic op( new Genetic::PhenotypeBinary( 45 ), 0.000125 ); | ||
| 19 | Genetic::Phenotype *pPb1 = op.random(); | ||
| 20 | |||
| 21 | Bu::MemBuf mb; | ||
| 22 | pPb1->write( mb ); | ||
| 23 | sio << "Size: " << mb.getSize() << sio.nl; | ||
| 24 | mb.setPos( 0 ); | ||
| 25 | |||
| 26 | Genetic::PhenotypeBinary b( 1 ); | ||
| 27 | b.read( mb ); | ||
| 28 | |||
| 29 | sio << pPb1->toString() << sio.nl; | ||
| 30 | sio << b.toString() << sio.nl; | ||
| 31 | |||
| 32 | delete pPb1; | ||
| 33 | |||
| 34 | return 0; | ||
| 35 | } | ||
| 36 | |||
