googlemock-使用::testing::An()
我在使用以下声明时收到编译错误:googlemock-使用::testing::An(),testing,googlemock,Testing,Googlemock,我在使用以下声明时收到编译错误: EXPECT_CALL(some_object, someFunction(1,An<AStructIDefined>())) .Times(2); An()是具有以下定义的Google模拟: // Creates a matcher that matches any value of the given type T. template <typename T> inline Matcher<T> An() { r
EXPECT_CALL(some_object, someFunction(1,An<AStructIDefined>()))
.Times(2);
An()是具有以下定义的Google模拟:
// Creates a matcher that matches any value of the given type T.
template <typename T>
inline Matcher<T> An() { return A<T>(); }
解决方案是将声明更改为:
EXPECT_CALL(some_object, someFunction(1,An<AStructIDefined>()))
.Times(2);
EXPECT\u调用(一些对象,一些函数(1,An()))
.次(2);
到
EXPECT\u调用(一些对象,一些函数(1,An()))
.次(2);
C++隐式地对函数参数强制转换
const
和reference&
,但google mock的声明似乎要求函数签名中出现的类型,而不是作为参数提交给函数的类型。您能提供AstructionDefined和?
// Creates a matcher that matches any value of the given type T.
template <typename T>
inline Matcher<T> An() { return A<T>(); }
namespace mynamespace {
class ABaseCLass
{
public:
virtual ~ABaseCLass(){};
virtual bool isValid() const = 0;
};
struct AStructIDefined : public ABaseCLass
{
public:
OrderStatusReport(SomeEnum1 e_, int i_, double d_);
SomeEnum1 e;
int i;
double d;
const std::string toString() const;
bool isSane() const;
bool operator== (const SomeEnum1& ref_) const;
double getD() const;
int getI() const;
bool isCondition() const;
};
} // namespace mynamespace
EXPECT_CALL(some_object, someFunction(1,An<AStructIDefined>()))
.Times(2);
EXPECT_CALL(some_object, someFunction(1,An<const AStructIDefined &>()))
.Times(2);