Skip to content

G-API: eliminate std::rand() and RAND_MAX from tests#18929

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
alalek:gapi_test_eliminate_rand
Nov 26, 2020
Merged

G-API: eliminate std::rand() and RAND_MAX from tests#18929
opencv-pushbot merged 1 commit intoopencv:masterfrom
alalek:gapi_test_eliminate_rand

Conversation

@alalek
Copy link
Copy Markdown
Member

@alalek alalek commented Nov 26, 2020

Compilation warning (clang):

modules/gapi/test/common/gapi_parsers_tests_common.hpp:214:59: warning:
implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]
        it.confidence = static_cast<float>(std::rand()) / RAND_MAX;
                                                        ~ ^~~~~~~~
/usr/include/stdlib.h:86:18: note: expanded from macro 'RAND_MAX'
#define RAND_MAX        2147483647
                        ^~~~~~~~~~

// test that we can obtain it via RMat.as<T>() method
TEST(RMat, UsageInBackend) {
int i = std::rand();
int i = 123456;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

123456 is definitely a random number. Is call of cv::RNG() equal to call of rand()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

randomization is not really necessary for this test case.

/cc @rgarnov

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why you didn't use analogue in this case? And i don't mind 123456.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link
Copy Markdown
Contributor

@mpashchenkov mpashchenkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems logical about parsers.

@opencv-pushbot opencv-pushbot merged commit 3c9d03c into opencv:master Nov 26, 2020
@alalek alalek mentioned this pull request Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants