[SERVER-36785] Add a way to convert STL containers and StringMaps to strings Created: 21/Aug/18 Updated: 29/Oct/23 Resolved: 31/Oct/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | None |
| Fix Version/s: | 6.2.0-rc0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Charlie Swanson | Assignee: | Billy Donahue |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | devtools-to-servicearch | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Sprint: | Service Arch 2022-11-14 | ||||||||
| Participants: | |||||||||
| Description |
|
This can help with debugging and logging. If we add an operator<<, I believe we could use things like ASSERT_EQ in test code (which really only makes sense for ordered types like vector or set). |
| Comments |
| Comment by Githook User [ 31/Oct/22 ] | |||||||
|
Author: {'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}Message: | |||||||
| Comment by Billy Donahue [ 31/Oct/22 ] | |||||||
|
Changed to use pythonic (a,b,...) for tuples. This distinguishes them from [a,b,...] sequences. E.g.:
| |||||||
| Comment by Billy Donahue [ 29/Oct/22 ] | |||||||
|
Confirmed maps don't print so good.
Yuck:
Will fix. | |||||||
| Comment by Billy Donahue [ 29/Oct/22 ] | |||||||
|
Hi spencer.jackson@mongodb.com. Though To get the nicer printing you used to have to use ASSERT_THAT but ASSERT_THAT has always been able to match types that don't have operator<< or anything else. It treats pretty printing as optional, and can fall back to ugly printing (hexdump), kind of akin to gdb. I also made a prettier printer as a fallback for enum classes which might not have an operator<<, to more thoroughly address the problem from the ticket. I know it supports pretty printing of sequences (anything with a .begin() and .end()). So e.g. std::vector<PRINTABLE> will show up as a nice delimited list. I don't remember if the std::pair and std::tuple are pretty printed nicely or not. It doesn't look like it, so StringMap might print as a delimited sequence of hexdumps. I should test that and fix it. Basically it's just adding another case to this big if/else trait dispatch ladder here: | |||||||
| Comment by Spencer Jackson [ 28/Oct/22 ] | |||||||
|
blake.oler@mongodb.com does | |||||||
| Comment by Lauren Lewis (Inactive) [ 24/Feb/22 ] | |||||||
|
We haven’t heard back from you for at least one calendar year, so this issue is being closed. If this is still an issue for you, please provide additional information and we will reopen the ticket. | |||||||
| Comment by Spencer Jackson [ 31/Aug/20 ] | |||||||
|
As of Structured Logging, the logging subsystem now knows how to record events from container objects. However, I believe the request still applies for unittests. Because I believe that is maintained by SA, I'm routing there. |