MCPcopy Create free account
hub / github.com/defold/defold / TestRand

Function TestRand

engine/dlib/src/test/test_math.cpp:98–116  ·  view source on GitHub ↗

out is [min, max, mean]

Source from the content-addressed store, hash-verified

96
97// out is [min, max, mean]
98void TestRand(float (*rand)(uint32_t* seed), uint32_t* seed, float* out)
99{
100 uint32_t iterations = 1000000;
101 float min = 1.0f;
102 float max = -1.0f;
103 float sum = 0.0f;
104 for (uint32_t i = 0; i < iterations; ++i)
105 {
106 float r = rand(seed);
107 if (min > r)
108 min = r;
109 if (max < r)
110 max = r;
111 sum += r;
112 }
113 out[0] = min;
114 out[1] = max;
115 out[2] = sum / iterations;
116}
117
118TEST(dmMath, Rand)
119{

Callers 1

TESTFunction · 0.85

Calls 1

randClass · 0.85

Tested by

no test coverage detected