merge successful with staging
[biocity.git] / src / test.cpp
blob028193c4013b66a2b8af2d4c625e348d95ca0d35
1 #include <iostream>
2 #include <string>
3 #include "ConfReader.hh"
4 #include "FuncSelect.hh"
5 #include <gsl/gsl_rng.h>
6 #include <gsl/gsl_cdf.h>
7 #include "World.hh"
8 #include <iomanip>
9 using namespace std;
11 int ConfReaderTest1();
12 int WorldProxTest();
13 int FuncSelectTest();
14 int NoFuncSelectTest(bool);
15 int GenRanTest();
17 int main()
19 int tests = 0;
20 int tests_complete = 0;
21 gsl_rng *r;
24 //ConfReaderTest1();
25 //WorldProxTest();
27 //FuncSelectTest();
28 GenRanTest();
30 return 0;
33 int GenRanTest()
35 gsl_rng *r;
36 const gsl_rng_type *T = gsl_rng_default;
37 r = gsl_rng_alloc(T);
39 for (int i = 0; i < 200000; i++)
41 cout<<gsl_rng_uniform( r )<<endl;
44 return 0;
47 int FuncSelectTest()
49 double myparams[2];
50 myparams[0] = 1;
51 myparams[1] = 2;
52 int len = 2;
54 FuncSelect my_func( "gsl_cdf_tdist_P", myparams, len, NULL);
55 double result;
56 result = my_func.evaluate();
57 cout<<"Returned: "<<setprecision(16)<<result<<endl;
60 int NoFuncSelectTest(bool fsOn = true)
62 double myparams[2];
63 myparams[0] = 0.5;
64 myparams[1] = 1;
65 int len = 2;
66 double sum = 0;
67 double temp;
68 double j;
69 FuncSelect my_func( "gsl_cdf_gaussian_P", myparams, len, NULL);
71 for (int i = 0; i < 100000; i++)
73 j = (double) i;
74 if ( fsOn )
76 temp = my_func.evaluate();
78 else
80 temp = gsl_cdf_gaussian_P( 0.5, myparams[1]);
82 sum+=temp;
85 cout<<sum<<endl;
88 int WorldProxTest()
90 World testW( 6, 20, 20);
91 testW.calc_proximity( 10 );
92 testW.print_proximity();
95 int ConfReaderTest1()
97 cout<<"ConfReaderTest1"<<endl;
99 int success = 0;
100 int time=0;
101 string scen = "sdsd";
102 ConfReader m( "bioc.conf" );
103 ConfReader n( "nonexistant.conf" );
104 cout<<m.success()<<"\t true"<<endl;
105 cout<<n.success()<<"\t false"<<endl;
106 m.field_int( "time", &time );
107 cout<<time<<endl;
108 m.field_string( "scenario", &scen);
109 cout<<scen<<endl;
110 // cout<<m.get_field_string("scenariof")<<";"<<endl;