[SERVER-70815] extend ASSERT macros to stringify literally anything Created: 24/Oct/22 Updated: 29/Oct/23 Resolved: 26/Oct/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 6.2.0-rc0 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Henrik Edin | Assignee: | Billy Donahue |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Sprint: | Service Arch 2022-10-31 | ||||||||
| Participants: | |||||||||
| Description |
|
To use enum class when asserting in unit tests using ASSERT_EQ (or anything built on ASSERT_COMPARE) you also need to define an operator<< for your enum class type. It would be nice if the assertion macros had a fallback for enum class that explicitly casts to the underlying type so the user does not have to add operator<< (or explicitly casting in unit tests) Another workaround exists which is to useĀ ASSERT_THAT(..., Eq(...)); which is also clunky. |
| Comments |
| Comment by Githook User [ 26/Oct/22 ] |
|
Author: {'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}Message: |
| Comment by Billy Donahue [ 25/Oct/22 ] |
|
This is quite easy to patch in, but I think we have a bigger goal for not much more effort, of just having the ASSERT_THAT and the ASSERT_EQ... facilities share a quality stringification component. This is a very quick one. |
| Comment by Billy Donahue [ 24/Oct/22 ] |
|
Wouldn't it be nice if the ASSERT_EQ-family of macros someday worked as well as those "clunky" ASSERT_THAT matchers? |