ApprovalTests.cpp icon indicating copy to clipboard operation
ApprovalTests.cpp copied to clipboard

`verifyAll` won't compile with some c++20 ranges view.

Open bogado opened this issue 4 years ago • 5 comments

The function verifyAll assumes that the Container has an associated type name value_type. This is not true for all views. The issue show up on "approvalTests.hpp:1656" for version 10.8.0.

 [&](typename Container::value_type e, std::ostream& s) {

bogado avatar Mar 11 '21 22:03 bogado

Thank you for reporting this.

Do you have any suggestions as to how to fix this, please? And how serious of a problem is this for you?

claremacrae avatar Mar 20 '21 23:03 claremacrae

Sorry - closed in error - and re-opened.

claremacrae avatar Mar 20 '21 23:03 claremacrae

To fix this I think that using std::iterator_traits would suffice. For example :

https://godbolt.org/z/8cG6b1x3Y

This would be friendly to older version of C++ and also be more portable. Depending on how you introduce the fix it might even work with old style sized arrays int[10] for instance.

bogado avatar Mar 23 '21 21:03 bogado

Hi Victor (I assume!)

Thanks for reporting this, and for the Godbolt link.

It's probably going to be a little while until we get to this, so as a suggestion in the meantime, if you haven't done it already, we'd suggest a workaround of writing something:

void verifyAllInRange(...)
{
    // convert range to a vector or similar
    Approvals::verifyAll(vector...) 
}

claremacrae avatar Mar 25 '21 16:03 claremacrae

Putting it on hold until either we move our tests to C++20 - or we have a CI build that builds on 20...

We can keep an eye on compiler support: https://en.cppreference.com/w/cpp/compiler_support

claremacrae avatar Aug 30 '21 16:08 claremacrae