Open imb opened 13 years ago
Exception verification is now available with fct_chk_ex in the tip.
Been thinking on this a little bit, and I think the start would include something like this:
namespace {
template<typename T>
eq(const T &, const T &) {
throw std::exception("not implemented");
}
} /* fct */
Now that's overly simplified but the idea is that certain types would specialize that template to get "equal" support for their type. So for instance to support a Foo type you would write,
namespace fct{
// specialized for foo
template<>
eq<Foo>(Foo &f1, Foo &f2) {
myproject::check_foo_likeness(f1,f2);
}
} // namespace foo
That's the rough sketch, but I was also thinking about adding a sort of "fct::repr" template specialization as well that lets you represent your object if there is a specialization, otherwise it falls back to a "this object at address X is not equal to that object at address Y" kind of representation. So quick example,
namespace fct {
template<>
std::string repr<Foo>(Foo const &f) {
return f.getName();
}
} // namespace fct
as an idea of how to do it. Then the "repr" can be used to hopefully produce meaningful error messages.
This issue should be 'open'.
I'd like all the standard string tests to support the std::string and std::wstring, I would also like to add a checker for verifying that an exception is correctly generated.