Closed claremacrae closed 4 years ago
When building against 8.7.0, this change fixes the build:
template <typename T,
typename Function,
+ typename = IsNotDerivedFromWriter<T>,
typename = Detail::EnableIfNotDerivedFromReporter<Function>>
static void
verify(const T& contents, Function converter, const Options& options = Options())
{
std::stringstream s;
converter(contents, s);
verify(s.str(), options);
}
In 10.0.0 we removed typename = Detail::EnableIfNotDerivedFromReporter<Function>
- but the extra IsNotDerivedFromWriter
is still required.
The problem only occurs once Reporter arguments are changed to Options.
If Reporter is passed in, there is no ambiguity. I think this is because the new custom ToString mechanism was only added to the new overloads that take Options, and not to the deprecated Reporter-based methods.
We do have tests for custom reporters, and we have an ExistingFileWriter (or similar), so I'm unsure what it is about the code in ApprovalTests.cpp.Qt that triggers this scenario...
I realise that I will in due course want to update this method so its Reporter argument becomes Options... For now, I wanted to make the smallest changes possible.
inline void verifyQImage(
const QImage& image,
const ApprovalTests::Reporter& reporter = ApprovalTests::DiffReporter())
{
QImageApprovalWriter image_writer(image);
ApprovalTests::Approvals::verify(image_writer, ApprovalTests::Options(reporter));
}
An alternative fix is to say that the Function type is not Options - which matches the previous constraint that Function was not derived from Reporter...
This is now fixed - I'll close the issue when we release.
This is in the 10.0.1 release, about to be completed
I've been updating ApprovalTests.cpp.Qt to use the latest ApprovalTests.cpp.
This is the code that now does not compile, once I wrap the reporter in
Options
:where
QImageApprovalWriter
implementsApprovalTests::ApprovalWriter
The error output is:
This is supposed to call this method:
But instead this method gets selected:
And the code attempts to call
options(contents, s)
which really doesn't have a call operator.