gpt4 book ai didi

c++ - this_thread::sleep_for 在 WSL 的谷歌测试中不起作用

转载 作者:行者123 更新时间:2023-12-02 10:28:45 26 4
gpt4 key购买 nike

我正在尝试在 Google 测试中 sleep 。根据this post ,我可以使用以下内容:

#include <chrono>
#include <thread>
TEST_F(TestSuite, TestOne) {
// f1();
std::this_thread::sleep_for(std::chrono::seconds(2));
// f2();
}
我将此命令放在测试中,但它不会改变任何东西。代码执行很快,因为它省略了 sleep 。我正在使用 g++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0。
我可能做错了什么?

最佳答案

你的测试真的执行了吗?我建议将临时 std::cout << "STARTING TEST" << std::endl;在测试开始时检查您是否可以在输出中看到这些单词。

关于c++ - this_thread::sleep_for 在 WSL 的谷歌测试中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63171696/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com