我使用我创建的结构作为参数值编写了一个参数化 Gtest。当测试失败时,它会写入结构的字节对象,如下所示:
[ FAILED ] RulesNoProcessing/StressTest.MainTest/2, where GetParam() =
40-byte object <01-12 00-00 02-00 00-00 F4-01 00-00 ...>.
有什么方法可以自定义输出吗?我知道断言有谓词格式,但我需要对测试的实际结果做类似的事情。如果有人可以帮助我,我将非常感激!
最佳答案
例如,您必须覆盖“运算符 <<”
struct Row
{
int window;
int osmap;
friend std::ostream& operator<<(std::ostream& os, const Row& bar) {
return os << "w = " << bar.window << ", opsmap= " << bar.osmap; // whatever needed to print
}
};
关于c++ - GTest改变失败的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48668841/