diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2012-05-22 16:57:15 +0000 | 
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2012-05-22 16:57:15 +0000 | 
| commit | 2295579eb790d6eff6e54e84c01da6de10809a71 (patch) | |
| tree | 3d8282dedc137fee009f71ff904370537009e504 /src/tests | |
| parent | 690ad7280e655654a3bcca2ca5ced9caacf75c8b (diff) | |
| download | libbu++-2295579eb790d6eff6e54e84c01da6de10809a71.tar.gz libbu++-2295579eb790d6eff6e54e84c01da6de10809a71.tar.bz2 libbu++-2295579eb790d6eff6e54e84c01da6de10809a71.tar.xz libbu++-2295579eb790d6eff6e54e84c01da6de10809a71.zip | |
Better win_o ignores.  The random number system is pretty much together.
We need a few extra helper functions to cover some other good things, like
normalized floating point numbers, etc.
Diffstat (limited to '')
| -rw-r--r-- | src/tests/random.cpp | 49 | 
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 | |||
| 7 | using namespace Bu; | ||
| 8 | |||
| 9 | template<typename T> | ||
| 10 | void 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 | |||
| 41 | int main() | ||
| 42 | { | ||
| 43 | coverage<RandomBasic>(); | ||
| 44 | coverage<RandomCmwc>(); | ||
| 45 | coverage<RandomSystem>(); | ||
| 46 | |||
| 47 | return 0; | ||
| 48 | } | ||
| 49 | |||
