-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
unit_tests: gtest utility ASSERT_EQ_MAP for easily testing key-value map #3245
Conversation
31e19ab
to
3eb4335
Compare
Are you going to PR the header change to Google? Because this forces everyone to uninstall libgtest and use the provided one to be able to compile unit_tests. |
Trying to build tests in MSYS2, after uninstalling mingw-w64-x86_64-gtest, produces the following output:
After applying changes from google/googletest#621, gtest and this PR built successfully, and all tests passed in unit_tests. |
The extra define can be moved to one of our files. |
3eb4335
to
6756d1f
Compare
@iDunk5400 @moneromooo-monero |
6756d1f
to
95b1e99
Compare
Out of curiosity, why GTEST_ASSERT_EQ and not the usual ASSERT_EQ ? |
95b1e99
to
54c256b
Compare
@moneromooo-monero #if !GTEST_DONT_DEFINE_ASSERT_EQ
# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
#endif makes a slight difference in that you can disable those macros by setting |
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.
Reviewed
When one wants to test for a map
m
whether it contains a particular key-value pair or not, doing something likeASSERT_EQ(value, m.find(key)->second)
will crash the whole test if the key isn't found in the map. Although currently there's no such instance in the test thanks to the test data being carefully prepared, this utility can be useful for avoiding the crash when writing new tests.