}
END_TEST;
}
-
-int UtcDaliRandomChanceMethod(void)
-{
- int bin_zero=0, bin_one=0;
-
- for(size_t i=0; i<100000; i++)
- {
- bool chance = Dali::Random::Chance();
- if(chance)
- {
- bin_one++;
- }
- else
- {
- bin_zero++;
- }
- }
- // Check distribution
- DALI_TEST_EQUALS((float)bin_zero / (float)bin_one, 1.0f, 0.1f, TEST_LOCATION);
-
- bin_zero=0; bin_one = 0;
- for(size_t i=0; i<100000; i++)
- {
- bool chance = Dali::Random::Chance(0.25);
- if(chance) {bin_one++;} else {bin_zero++;}
- }
- // Check distribution
- DALI_TEST_EQUALS((float)bin_zero / (float)bin_one, 3.0f, 0.1f, TEST_LOCATION);
-
- bin_zero=0; bin_one = 0;
- for(size_t i=0; i<100000; i++)
- {
- bool chance = Dali::Random::Chance(0.1);
- if(chance) {bin_one++;} else {bin_zero++;}
- }
- // Check distribution
- DALI_TEST_EQUALS((float)bin_zero / (float)bin_one, 9.0f, 0.1f, TEST_LOCATION);
- END_TEST;
-}
return axis;
}
-/**
- * @brief Returns true if the value given is greater than a random value between 0 and 1.
- *
- * @param chance A value between 0 and 1. [Default: 0.5]
- * @return true if chance greater than the random value, otherwise false.
- */
-inline bool Chance(float chance = 0.5f)
-{
- return chance > Range(0.0f, 1.0f);
-}
-
} // namespace Random
} // namespace Dali