I'm trying to test EXPECT_THROW, like below.
#include <gtest/gtest.h>
int Foo(int a, int b){
if (a == 0 || b == 0){
throw "don't do that";
}
int c = a % b;
if (c == 0)
return b;
return Foo(b, c);
}
TEST(FooTest, Throw2){
EXPECT_THROW(Foo(0,0), char*);
}
int main(int argc, char* argv[]){
testing::InitGoogleTest(&argc,argv);
return RUN_ALL_TESTS();
}
I expect that the 'Throw2' should succeed. But it gives this error information:
Expected: Foo(0,0) throws an exception of type char*.
Actual: it throws a different type.
So what is type being thrown here?
Aucun commentaire:
Enregistrer un commentaire