Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

I have a fixture class FooTest, but TEST_F(FooTest, Bar) gives me error “no matching function for call to FooTest::FooTest()”. Why?

0
Posted

I have a fixture class FooTest, but TEST_F(FooTest, Bar) gives me error “no matching function for call to FooTest::FooTest()”. Why?

0

Google Test needs to be able to create objects of your test fixture class, so it must have a default constructor. Normally the compiler will define one for you. However, there are cases where you have to define your own: • If you explicitly declare a non-default constructor for class FooTest, then you need to define a default constructor, even if it would be empty. • If FooTest has a const non-static data member, then you have to define the default constructor and initialize the const member in the initializer list of the constructor. (Early versions of gcc doesn’t force you to initialize the const member.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.