History

Don't reset the random number generator within the unit tests

This makes sure we don't accidentally return the same sequence of random numbers multiple times within one test (which would be very non-random). Every time srand(time()) is called, the pseudo random number generator is initialized to the same value (as long as time() returned the same value). By initializing the random number generator once and for all before starting to run the unit tests, we are sure we don't need to reinitialize it within all the tests and all the functions that use random numbers. This fixes occasional errors in MotionEstimateTest. MotionEstimateTest was designed to allow the test to occasionally not succeed - if it didn't succeed, it tried again, up to 100 times. However, since the YUVPixelDataGenerator function reset the random seed to time(), every attempt actually ran with the same random data (as long as all 100 attempts ran within 1 second) - thus if one attempt in MotionEstimateTest failed, all 100 of them would fail. If the utility functions don't touch the random seed, this is not an issue.

Martin Storsjö committed 12 years ago

Commit 4f594de1 parent 806e59f16 files · +12 −114Browse files

Showing the changes to test/processing/ProcessUT_ScrollDetection.cpp (1 of 16 files). Show all

Unified · Split

test/processing/ProcessUT_ScrollDetection.cpp+1−2
@@ -21,7 +21,6 @@ TEST (ScrollDetectionTest, TestScroll) { · 20 unmodified lines
2121 int iWidthSets[4] = {640, 1024, 1280, 1980};
2222 int iHeightSets[4] = {360, 768, 720, 1080};
2323 int iStride = 0;
24− int iIdx = 0;
2524
2625 for (int i = 0; i < 4; i++) {
2726 int iWidth = iWidthSets[i];
@@ -31,7 +30,7 @@ TEST (ScrollDetectionTest, TestScroll) { · 3 unmodified lines
3130 ASSERT_TRUE (NULL != pSrc);
3231 pRef = new unsigned char[iHeight * iStride];
3332 ASSERT_MEMORY_FAIL2X (pSrc, pRef)
34− RandomPixelDataGenerator (pRef, iWidth, iHeight, iStride, iIdx);
33+ RandomPixelDataGenerator (pRef, iWidth, iHeight, iStride);
3534
3635 int iMvRange = iHeight / 3;
3736 int iScrollMv = rand() % (iMvRange << 1) - iMvRange;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t