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
With the following little program, an uncaught exception is provoked.
#include "single_header/standalone/fakeit.hpp"
using namespace fakeit;
class NotDefaultConstructible
{
public:
NotDefaultConstructible(int a){}
};
class ToMock
{
public:
virtual NotDefaultConstructible MyFunc() = 0;
};
int main()
{
Mock<ToMock> myMock;
Fake(Method(myMock, MyFunc));
myMock.get().MyFunc();
}
If this exception is thrown when fakeit is used in combination with BOOST Test, the exception text of boost says: unknown type and with unknown type the exception type "DefaultValueInstatiationException" is meant. I don't know who is trying to catch such an exception type. It would be much more useful in this context to see a proper error description in the print output, which is already included in the .what().
I don't know if the following statement covers all use cases, but for me it would be easier to have a failing static_assertion if the return type of a faked function has no default constructor. This would therefore force the user to use "When" and to manually return something.
The check for this would look similar to this:
using ReturnType = decltype(myMock.get().MyFunc());
static_assert(std::is_constructible<ReturnType>());
The text was updated successfully, but these errors were encountered:
With the following little program, an uncaught exception is provoked.
If this exception is thrown when fakeit is used in combination with BOOST Test, the exception text of boost says: unknown type and with unknown type the exception type "DefaultValueInstatiationException" is meant. I don't know who is trying to catch such an exception type. It would be much more useful in this context to see a proper error description in the print output, which is already included in the .what().
I don't know if the following statement covers all use cases, but for me it would be easier to have a failing static_assertion if the return type of a faked function has no default constructor. This would therefore force the user to use "When" and to manually return something.
The check for this would look similar to this:
The text was updated successfully, but these errors were encountered: