【发布时间】:2021-05-16 11:05:04
【问题描述】:
我已经开始学习如何使用 Catch2 来测试我的 C++ 代码,并且正在尝试设置一个简单的测试。
我的文件夹结构包含三个文件都在同一个文件夹中:
catch.cpp //this is the catch_amalgamated.cpp file from GitHub
catch.hpp //this is the catch_amalgamated.hpp file from GitHub
test.cpp //this is my test file
我在test.cpp 中写的都是:
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
当我尝试编译 test.cpp 时,我收到以下错误,我认为这表明没有找到 main() 函数(?):
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
当我添加一个名义上的 main() 函数时,文件编译成功,但据我了解,#define CATCH_CONFIG_MAIN 应该为您创建 main() 函数,所以显然有些东西不起作用。
任何人都可以对此有所了解吗?
【问题讨论】:
标签: c++ unit-testing testing catch2