如何为以回调函数为参数的函数编写单元测试?
unsigned __int32
MyStream::DoThis(callBackFunction in_Function,
unsigned __int32 in_Length)
{
//some code
//some code
return readStream->DoThis(in_Function, dataLength);
}
最佳答案
- 创建一个 stub 回调函数,在其主体内引发标志。
- 调用您的 UT 并将 stub 作为参数传递给您的函数。
- 执行完成后断言标志已升起。
关于c++ - 如何为将回调作为参数的函数编写单元测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13445900/