summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/random.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/tests/random.cpp b/src/tests/random.cpp
new file mode 100644
index 0000000..3799803
--- /dev/null
+++ b/src/tests/random.cpp
@@ -0,0 +1,49 @@
1#include <bu/randombasic.h>
2#include <bu/randomcmwc.h>
3#include <bu/randomsystem.h>
4#include <bu/sio.h>
5#include <time.h>
6
7using namespace Bu;
8
9template<typename T>
10void coverage()
11{
12 T rand;
13 rand.seed( time( NULL ) );
14
15 uint32_t uBucket[78];
16 memset( uBucket, 0, sizeof(uint32_t)*78 );
17
18 for( int j = 0; j < 1000000; j++ )
19 {
20 uBucket[(int)(((uint32_t)rand.rand())/(double)(0xfffffffful)*78+0.5)]++;
21 }
22
23 uint32_t uMax = 0;
24 for( int j = 0; j < 78; j++ )
25 {
26 if( uMax < uBucket[j] )
27 uMax = uBucket[j];
28 }
29
30 for( int y = 20; y >= 1; y-- )
31 {
32 uint32_t iT = (uint32_t)((y/20.0)*uMax);
33 for( int x = 0; x < 78; x++ )
34 {
35 sio << ((iT<=uBucket[x])?"#":" ");
36 }
37 sio << sio.nl;
38 }
39}
40
41int main()
42{
43 coverage<RandomBasic>();
44 coverage<RandomCmwc>();
45 coverage<RandomSystem>();
46
47 return 0;
48}
49