Backported RNG_MT19937 from master.
This commit is contained in:
@@ -339,3 +339,29 @@ protected:
|
||||
|
||||
TEST(Core_Rand, range) { Core_RandRangeTest test; test.safe_run(); }
|
||||
|
||||
|
||||
TEST(Core_RNG_MT19937, regression)
|
||||
{
|
||||
cv::RNG_MT19937 rng;
|
||||
int actual[61] = {0, };
|
||||
const size_t length = (sizeof(actual) / sizeof(actual[0]));
|
||||
for (int i = 0; i < 10000; ++i )
|
||||
{
|
||||
actual[(unsigned)(rng.next() ^ i) % length]++;
|
||||
}
|
||||
|
||||
int expected[length] = {
|
||||
177, 158, 180, 177, 160, 179, 143, 162,
|
||||
177, 144, 170, 174, 165, 168, 168, 156,
|
||||
177, 157, 159, 169, 177, 182, 166, 154,
|
||||
144, 180, 168, 152, 170, 187, 160, 145,
|
||||
139, 164, 157, 179, 148, 183, 159, 160,
|
||||
196, 184, 149, 142, 162, 148, 163, 152,
|
||||
168, 173, 160, 181, 172, 181, 155, 153,
|
||||
158, 171, 138, 150, 150 };
|
||||
|
||||
for (size_t i = 0; i < length; ++i)
|
||||
{
|
||||
ASSERT_EQ(expected[i], actual[i]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user