小编Sen*_*ns4的帖子

使用 Visual Studio 2019 和 cmake 进行谷歌测试

我正在尝试使用 Visual Studio 2019 和 cmake 设置 google 测试。

这是我的 CMakeFileLists.txt 内容:

cmake_minimum_required(VERSION 3.0)
project(test_me)

# GTest
enable_testing()
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})

# Unit Tests
# Add test cpp file
add_executable( runUnitTests tests.cpp)
# Link test executable against gtest & gtest_main
target_link_libraries(runUnitTests ${GTEST_BOTH_LIBRARIES})
add_test( runUnitTests runUnitTests )
Run Code Online (Sandbox Code Playgroud)

我的tests.cpp 文件如下所示:

#include <gtest/gtest.h>

TEST(ABC, TEST1) {
    EXPECT_EQ(true, true);
}

TEST(ABC, TEST2) {
    ASSERT_TRUE(2 == 2);
}
Run Code Online (Sandbox Code Playgroud)

这个最小的例子来自另一个 stackoverflow 问题: CMake file forintegrated Visual Studio unittesting

这就是我构建应用程序后得到的结果: 在此输入图像描述

名为 runUnitTests 的单个测试。然而,在上面问题的答案图片中,我希望看到每个测试函数的名称。像这样的东西:

runUnitTests
- ABC
  - …
Run Code Online (Sandbox Code Playgroud)

c++ unit-testing cmake googletest visual-studio

8
推荐指数
1
解决办法
8743
查看次数

opengl如何画动态线?

我想在 OpenGL 中画一条线,它经常会收到新的点。

我想实现一个在其自身后面画一条线的对象:

在此输入图像描述

那么我是否必须创建一个数组并将所有新点附加到它(BufferData设置为GL_DYNAMIC_DRAW)。然后用 重新绘制线条glDrawArrays。镶嵌+笔划宽度将在vertexshader

或者,还有更好的方法?

opengl line draw

5
推荐指数
1
解决办法
2034
查看次数

在 python 中,await 之前不会在异步函数中调用 print 函数

我想获得一些与 requests 和 asyncio 的链接。我有一个示例程序,但我认为存在问题,因为只有当我使用 wait 时才会调用 print 函数。

那么为什么在我调用实际函数的地方没有调用 print 呢?据我所知,如果使用await关键字,该函数就会中断,直到未来出现。就我而言,应该在await关键字之前调用print函数,也就是在print语句之前调用:doing stuff in between还是我错了?

import asyncio
import requests
import bs4

urls = ["http://www.google.com", "http://www.google.co.uk"]

async def getContent(url):
    loop = asyncio.get_event_loop()
    print("getting content for: " + url) # print should be called here
    # execute a non async function async
    future = loop.run_in_executor(None, requests.get, url)

    # doing stuff with bs4
    soup = bs4.BeautifulSoup((await future).text, "html.parser") # should now interrupt

    return soup 

async def main():
    loop = asyncio.get_event_loop()

    print("starting …
Run Code Online (Sandbox Code Playgroud)

python asynchronous python-requests python-asyncio python-3.5

5
推荐指数
1
解决办法
2万
查看次数