我有以下方法:
QMap<QString, int> DefaultConfig::getConfig()
{
QMap<QString, int> result;
result.insert("Error", LOG_LOCAL0);
result.insert("Application", LOG_LOCAL1);
result.insert("System", LOG_LOCAL2);
result.insert("Debug", LOG_LOCAL3);
result.insert("Trace", LOG_LOCAL4);
return result;
}
我尝试编写可以返回测试中准备的 QMap 的模拟:
QMap<QString, int> DefaultConfig::getConfig() {
mock().actualCall("getConfig");
return ?
}
但我不知道如何模拟返回值?我想在TEST
函数中以下列方式使用模拟:
QMap<QString, int> fake_map;
fake_map.insert("ABC", 1);
mock().expectOneCall("getConfig").andReturnValue(fake_map);
我在 CppUTest Mocking 文档中找不到这样的示例。我也知道.andReturnValue
这种形式也行不通。