Co-Simulation/Sumo/sumo-1.7.0/unittest/src/utils/common/RandHelperTest.cpp
/* Test whether the 'rand' distribution is more or less uniform.*/
Test whether the 'rand' distribution is more or less uniform.
Test whether the ' rand ' distribution is more or less uniform .
TEST(RandHelper, test_uniform) {
    int count[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    for (int i = 0; i < 1000; i++) {
        const double rand = RandHelper::rand(0., double(10));
        count[(int)rand]++;
    }
    for (int i = 0; i < 10; i++) {
        EXPECT_LE(50, count[i]) << "Testing interval " << i;
        EXPECT_LT(count[i], 150) << "Testing interval " << i;
    }
}
TEST ( RandHelper , test_uniform ) { int count [ ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; for ( int i = 0 ; i < 1000 ; i ++ ) { const double rand = RandHelper :: rand ( 0. , double ( 10 ) ) ; count [ ( int ) rand ] ++ ; } for ( int i = 0 ; i < 10 ; i ++ ) { EXPECT_LE ( 50 , count [ i ] ) << " " << i ; EXPECT_LT ( count [ i ] , 150 ) << " " << i ; } }
Test whether the 'rand' distribution is more or less uniform.
Test whether the ' rand ' distribution is more or less uniform .