C++ 无法在运行Apple LLVM 10.0.1版的mac上捕获2 hello测试
我只是在尝试我的教程来尝试catch2单元测试库。我用10.14的mac电脑。 我没有完整的XCode,只有cmd工具和macports在我的设置中运行完美(没有brew)。 我使用合并的单头文件和源文件的建议 然而,一个简单的教程:C++ 无法在运行Apple LLVM 10.0.1版的mac上捕获2 hello测试,c++,unit-testing,tdd,catch2,C++,Unit Testing,Tdd,Catch2,我只是在尝试我的教程来尝试catch2单元测试库。我用10.14的mac电脑。 我没有完整的XCode,只有cmd工具和macports在我的设置中运行完美(没有brew)。 我使用合并的单头文件和源文件的建议 然而,一个简单的教程: #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file #include "catch.hpp" un
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
unsigned int Factorial( unsigned int number ) {
return number <= 1 ? number : Factorial(number-1)*number;
}
TEST_CASE( "Factorials are computed", "[factorial]" ) {
REQUIRE( Factorial(1) == 1 );
REQUIRE( Factorial(2) == 2 );
REQUIRE( Factorial(3) == 6 );
REQUIRE( Factorial(10) == 3628800 );
}
请推荐,谢谢
编辑:
@Tiib建议尝试使用
g++-std=c++17
后,代码被编译并生成g++-std=c++11
也不起作用。不明白为什么。您试图用什么命令编译代码?看来你在某些C++ 11模式下运行编译器,C++ 11确实改变了C++语法。只是做了<代码> GCC Test1.CPP。有没有其他方法来构建测试?试试gcc-std=c++11 test1.cpp输出都是一样的。嗯,但是clang++-std=c++11 test1.cpp
In file included from test1.cpp:2:
./catch.hpp:75:49: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
NonCopyable( NonCopyable const& ) = delete;
^
./catch.hpp:76:37: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
NonCopyable( NonCopyable&& ) = delete;
^
./catch.hpp:76:44: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
NonCopyable( NonCopyable&& ) = delete;
^
./catch.hpp:77:60: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
NonCopyable& operator=( NonCopyable const& ) = delete;
^
./catch.hpp:78:48: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
NonCopyable& operator=( NonCopyable&& ) = delete;
^
./catch.hpp:78:55: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
NonCopyable& operator=( NonCopyable&& ) = delete;
^
./catch.hpp:81:26: error: expected ';' at end of declaration list
NonCopyable() noexcept = default;
^
;