From e9cfcc6dfc8427904ab227eea2452ccddd8f295c Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 5 Aug 2012 01:27:43 -0600 Subject: Added I/O test for binary phenotypes. --- src/tests/io.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/tests/io.cpp 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 @@ +#include "genetic/phenotypebinary.h" +#include "genetic/operatorbasic.h" + +#include +#include +#include +#include +#include +#include + +using namespace Bu; + +int main( int argc, char *argv[] ) +{ + Bu::Random::setGenerator(); + Bu::Random::seed( time( NULL ) ); + + Genetic::OperatorBasic op( new Genetic::PhenotypeBinary( 45 ), 0.000125 ); + Genetic::Phenotype *pPb1 = op.random(); + + Bu::MemBuf mb; + pPb1->write( mb ); + sio << "Size: " << mb.getSize() << sio.nl; + mb.setPos( 0 ); + + Genetic::PhenotypeBinary b( 1 ); + b.read( mb ); + + sio << pPb1->toString() << sio.nl; + sio << b.toString() << sio.nl; + + delete pPb1; + + return 0; +} + -- cgit v1.2.3