00001 00033 #include <tut/tut.h> 00034 00035 #include "linden_common.h" 00036 #include "llrand.h" 00037 #include "lltut.h" 00038 00039 00040 namespace tut 00041 { 00042 struct random 00043 { 00044 }; 00045 00046 typedef test_group<random> random_t; 00047 typedef random_t::object random_object_t; 00048 tut::random_t tut_random("random"); 00049 00050 template<> template<> 00051 void random_object_t::test<1>() 00052 { 00053 F32 number = 0.0f; 00054 for(S32 ii = 0; ii < 100000; ++ii) 00055 { 00056 number = ll_frand(); 00057 ensure("frand >= 0", (number >= 0.0f)); 00058 ensure("frand < 1", (number < 1.0f)); 00059 } 00060 } 00061 00062 template<> template<> 00063 void random_object_t::test<2>() 00064 { 00065 F64 number = 0.0f; 00066 for(S32 ii = 0; ii < 100000; ++ii) 00067 { 00068 number = ll_drand(); 00069 ensure("drand >= 0", (number >= 0.0)); 00070 ensure("drand < 1", (number < 1.0)); 00071 } 00072 } 00073 00074 template<> template<> 00075 void random_object_t::test<3>() 00076 { 00077 F32 number = 0.0f; 00078 for(S32 ii = 0; ii < 100000; ++ii) 00079 { 00080 number = ll_frand(2.0f) - 1.0f; 00081 ensure("frand >= 0", (number >= -1.0f)); 00082 ensure("frand < 1", (number <= 1.0f)); 00083 } 00084 } 00085 00086 template<> template<> 00087 void random_object_t::test<4>() 00088 { 00089 F32 number = 0.0f; 00090 for(S32 ii = 0; ii < 100000; ++ii) 00091 { 00092 number = ll_frand(-7.0); 00093 ensure("drand <= 0", (number <= 0.0)); 00094 ensure("drand > -7", (number > -7.0)); 00095 } 00096 } 00097 00098 template<> template<> 00099 void random_object_t::test<5>() 00100 { 00101 F64 number = 0.0f; 00102 for(S32 ii = 0; ii < 100000; ++ii) 00103 { 00104 number = ll_drand(-2.0); 00105 ensure("drand <= 0", (number <= 0.0)); 00106 ensure("drand > -2", (number > -2.0)); 00107 } 00108 } 00109 00110 template<> template<> 00111 void random_object_t::test<6>() 00112 { 00113 S32 number = 0; 00114 for(S32 ii = 0; ii < 100000; ++ii) 00115 { 00116 number = ll_rand(100); 00117 ensure("rand >= 0", (number >= 0)); 00118 ensure("rand < 100", (number < 100)); 00119 } 00120 } 00121 00122 template<> template<> 00123 void random_object_t::test<7>() 00124 { 00125 S32 number = 0; 00126 for(S32 ii = 0; ii < 100000; ++ii) 00127 { 00128 number = ll_rand(-127); 00129 ensure("rand <= 0", (number <= 0)); 00130 ensure("rand > -127", (number > -127)); 00131 } 00132 } 00133 }