Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
googlemock-使用::testing::An()_Testing_Googlemock - Fatal编程技术网

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);