Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/160.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
C++ 让Google测试框架输出用户定义的类型_C++_Unit Testing_Namespaces_Operator Overloading - Fatal编程技术网

C++ 让Google测试框架输出用户定义的类型

C++ 让Google测试框架输出用户定义的类型,c++,unit-testing,namespaces,operator-overloading,C++,Unit Testing,Namespaces,Operator Overloading,我想在提到的测试框架中输出我的类型。这是可能的 如前所述,打印机是可扩展的。这意味着您可以教它更好地打印您的特定类型,而不是转储字节。为此,定义您似乎已经定义了运算符您似乎已经定义了运算符谢谢。来自编译器的消息可能会非常混乱,尽管这可能不是最糟糕的消息。当只有一个具有特定名称的函数时,编译器会告诉您哪些参数与预期的不匹配,从而提供帮助。但当多个函数与请求的名称匹配时(operator谢谢。来自编译器的消息可能会非常混乱,尽管这可能不是最糟糕的消息。如果只有一个函数具有特定名称,编译器会告诉您哪些

我想在提到的测试框架中输出我的类型。这是可能的


如前所述,打印机是可扩展的。这意味着您可以教它更好地打印您的特定类型,而不是转储字节。为此,定义您似乎已经定义了
运算符您似乎已经定义了
运算符谢谢。来自编译器的消息可能会非常混乱,尽管这可能不是最糟糕的消息。当只有一个具有特定名称的函数时,编译器会告诉您哪些参数与预期的不匹配,从而提供帮助。但当多个函数与请求的名称匹配时(
operator谢谢。来自编译器的消息可能会非常混乱,尽管这可能不是最糟糕的消息。如果只有一个函数具有特定名称,编译器会告诉您哪些参数与预期不匹配,这会很有帮助。但是当多个函数与请求的名称匹配时(
operator
namespace foo {

class Bar { ... };

// It's important that PrintTo() is defined in the SAME
// namespace that defines Bar.  C++'s look-up rules rely on that.
void PrintTo(const Bar& bar, ::std::ostream* os) {
     *os << bar.DebugString();  // whatever needed to print bar to os
}

}  // namespace foo
error: no match for ‘operator<<’ in ‘* os << val’ /usr/include/c++/4.4/ostream:108: note: candidates are:
std::ostream& Navmii::ProgrammingTest::operator<<(std::ostream&, Navmii::ProgrammingTest::AsciiString&)
std::ostream& Navmii::ProgrammingTest::operator<<(
  std::ostream&,
  Navmii::ProgrammingTest::AsciiString const&);