0

我正在尝试在 main 函数中运行测试,但显示错误“您无法重载 main () 函数”。

#define CATCH_CONFIG_RUNNER // -- main() создавать нужно --
#include "catch.hpp"
int main(int argc, char* argv[])
{
    setlocale(LC_ALL, "Russian");
    int result = Catch::Session().run(argc, argv);
    system("pause");
    return result;
}
4

1 回答 1

0

您应该以其他方式使用Catch 。类似的东西对我有用:

#include <iostream> // some standard includes, whatever you need

#define CATCH_CONFIG_MAIN
#include "catch.hpp"

TEST_CASE("My first test") {
    // --- test code here ---
}

TEST_CASE("My second test") {
    // --- test code here ---
}

尝试框架的教程以了解更多信息 =)

于 2019-05-04T16:06:14.103 回答