谷歌测试中的使用线程
Usage threads in google tests
我想创建一些测试来检查应用程序中的多线程。我使用谷歌测试框架。我的以下代码未使用错误消息进行编译error: invalid use of non-static member function
TEST_F( tc, t ) {
std::thread thread1 ( f1, p1 );
std::thread thread2 ( f2, p2 );
thread1.join();
thread2.join();
}
我使用 GCC 5.2.1 进行编译。
你能指出我热解决它吗?
你需要告诉 std::threadf1 和 f2 是你的测试夹具的方法,使用 std::bind
:
TEST_F( tc, t ) {
std::thread thread1(std::bind(&tc::f1, this, p1));
std::thread thread2(std::bind(&tc::f2, this, p2));
thread1.join();
thread2.join();
}
相关文章:
- MS 本机单元测试 - 断言::线程失败不起作用
- 使用 std::chrono::steady_clock 对线程/异步中的代码进行基准测试
- 为什么我不能编译这个简单的线程测试?
- 线程池的计时测试:单线程 vs 回调 tp vs 未来 tp
- 测试队列中等待condition_variables的多个线程
- 如何在Visual Studio中设置C /C代码仅在一个线程中运行以测试运行时间
- 对线程性能进行基准测试
- 提升线程链接在 Netbeans 7.1 调试/测试会话中失败
- 如何使用谷歌测试与线程
- 生产者和使用者函数,用于在操作手册中测试C++并发的线程安全堆栈示例
- 对多线程输入的QTableWidget进行基准测试,结果很奇怪
- Boost单元测试可以是多线程的吗
- 为什么我不能在 Boost.Test 测试用例中创建线程?
- 有没有什么方法可以测试C++API(在ubuntu-linux上)是否是重新集中的(线程安全的)
- 在自动测试后安全地清理阻塞的std::线程
- PC多线程性能和稳定性问题的简单基准测试.如何使每个线程在单独的核心上运行
- 测试静态局部对象的初始化是否线程安全
- 如何测试一个std::线程是否从
- c++线程速度测试,我做得对吗?
- 线程池性能测试