diff options
-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 | |||