You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What about providing an Approx that can be specialised just the same way as StringMaker<> in order to apply it to custom data types.
What about providing standard specializations for iterable types?
Pull request #557 aims at a container implementation. However, I think this could/should be generalized.
I came up with the following specific implementation for comapring Qt's QMatrix4x4. Unfortunately, having to initialize base class Approx with a single double is just misleading:
namespace {
class MApprox : public Catch::Detail::Approx {
public:
explicit MApprox(const QMatrix4x4& matrix) : Approx(0.0f), matrix_(matrix) {}
friend bool operator==(const QMatrix4x4& lhs, const MApprox& rhs) {
bool result = true;
for (int row = 0; row < 4; ++row) {
for (int col = 0; col < 4; ++col) {
result &= (lhs(row, col) == Approx(rhs.matrix_(row, col)));
}
}
return result;
}
const QMatrix4x4& Matrix() const { return matrix_; }
private:
QMatrix4x4 matrix_;
};
} // namespace
As a side-note: This is my specialization of StringMaker<>:
Approx
that can be specialised just the same way asStringMaker<>
in order to apply it to custom data types.Pull request #557 aims at a container implementation. However, I think this could/should be generalized.
I came up with the following specific implementation for comapring Qt's
QMatrix4x4
. Unfortunately, having to initialize base classApprox
with a singledouble
is just misleading:As a side-note: This is my specialization of
StringMaker<>
:And this is the test verifying that
MApprox
works as desired:The text was updated successfully, but these errors were encountered: