From 2295579eb790d6eff6e54e84c01da6de10809a71 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 22 May 2012 16:57:15 +0000 Subject: 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. --- src/tests/random.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/tests/random.cpp (limited to 'src/tests/random.cpp') 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 @@ +#include +#include +#include +#include +#include + +using namespace Bu; + +template +void coverage() +{ + T rand; + rand.seed( time( NULL ) ); + + uint32_t uBucket[78]; + memset( uBucket, 0, sizeof(uint32_t)*78 ); + + for( int j = 0; j < 1000000; j++ ) + { + uBucket[(int)(((uint32_t)rand.rand())/(double)(0xfffffffful)*78+0.5)]++; + } + + uint32_t uMax = 0; + for( int j = 0; j < 78; j++ ) + { + if( uMax < uBucket[j] ) + uMax = uBucket[j]; + } + + for( int y = 20; y >= 1; y-- ) + { + uint32_t iT = (uint32_t)((y/20.0)*uMax); + for( int x = 0; x < 78; x++ ) + { + sio << ((iT<=uBucket[x])?"#":" "); + } + sio << sio.nl; + } +} + +int main() +{ + coverage(); + coverage(); + coverage(); + + return 0; +} + -- cgit v1.2.3