-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/qgstest improv #58212
base: master
Are you sure you want to change the base?
Fix/qgstest improv #58212
Conversation
…ected file content. This check allows to read expected data from file and to compare the actual and expected content chunk by chunk. This chunk by chunk is need as for long QString or QByteArray, only the start of strings are displayed when error occurs. Hexadecimal and string content are displayed when a diff occurs.
… QTest::compare_helper
… an expected file content.
FYI the output in case of failure is something like that:
|
… an expected file content.
… an expected file content.
@lbartoletti @nyalldawson ready for review! I had tested the test function with a small test, I am wondering if I should create and keep a unittest to test this new function? |
|
||
if ( actualStr.size() != expectedStr.size() ) | ||
{ | ||
qWarning() << "Array have not the same length (actual vs expected):" << actualStr.size() << "vs" << expectedStr.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this fail? Eg if the actual string is a truncated version of expected, then the test will currently pass...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from what I have tested, this works fine but maybe I did not understand what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that if something regresses and starts giving a shorter string, this test will warm but still pass. It should definitely fail if the strings are different lengths...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the test will fail just after in the for loop when it will compare portions of the expected and the actual. Even if one of the actual or expected string are empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but you're only looping through up to strSize, which is defined as actualStr.size(). So if the expectedStr.size() is greater than the actualStr.size(), you'll never compare those missing bits of actualStr to what they should be.
I think line 319 should be const int strSize = std::max( actualStr.size(), expectedStr.size() );
Add a fix and a feature to qgstest: