Skip to content
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

std::array doesn't have a default printer. #192

Open
DenisYaroshevskiy opened this issue Mar 11, 2019 · 3 comments
Open

std::array doesn't have a default printer. #192

DenisYaroshevskiy opened this issue Mar 11, 2019 · 3 comments
Labels
category/strings Issues related to stringification of types and variables type/feature-proposal

Comments

@DenisYaroshevskiy
Copy link

Hi.

For std::array comparison I get:
REQUIRE( {?} == {?} )
I believe you support this for other containers. Can you add this when/if you have the time?

@onqtam
Copy link
Member

onqtam commented Mar 11, 2019

@DenisYaroshevskiy This isn't currently supported for any container from the STL by doctest - Catch2 does that. I might provide a second header with extensions and provide stringification for the most common containers/STL Types (because the main header will never include any STL/whatever header - the reason doctest compiles so fast).

Also default printers for containers is tricky - what if the container has 1 million elements? Would you want a short list of indexes that vary or an entire dump? A one-size-fits-all solution does not exist. You might write your own printers for types.

A related issue is printing ENUM values which will also go into such an extension header - see this: #121

@DenisYaroshevskiy
Copy link
Author

DenisYaroshevskiy commented Mar 11, 2019

@onqtam Oh - I see.

You do rely on ADL though for looking up types <=> for std ones it's not nice to do so.
Can I specialize smth instead?

UPD: Oh - I see - namespace dockets template<> struct StringMaker<T> {

  • How about for generic test? I don't know what your minimal language requirements, but if you do it based on having nested iterator type, you should be OK even for 98.
  • What if 1 million? Good point. Well - dump all is a very decent default if you could override it.

@onqtam
Copy link
Member

onqtam commented Mar 11, 2019

C++11 is the requirement for doctest 2.x (no longer C++98).

I think this is how Catch2 detects ranges.

I might implement matchers at some point and in that case when comparing containers you would get automatically the index that points to the different elements - this would be very hard to do with the current stringification of the values.

But currently I'm focusing on finishing the XML reporter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category/strings Issues related to stringification of types and variables type/feature-proposal
Projects
None yet
Development

No branches or pull requests

3 participants