For example, I have a code like:
TEST_F(Testmyexception, testthrownexception)
{
EXPECT_THROW(throw new myexception(), myexception);
}
After compiling and running, it gives an error: Actual: it throws a different type.
Does anynone know the answer?
Thanks,
You're throwing a pointer to a myexception
, so you have to expect a pointer in the check:
EXPECT_THROW(throw new myexception(), myexception*);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With