[英]cmake error when building Boost unit tests
I'm working through this tutorial, using VS2012 on a c++ project generated by cmake 3.0.2. 我正在本教程中工作,在cmake 3.0.2生成的c ++项目上使用VS2012。 http://help.exercism.io/getting-started-with-cpp.html
http://help.exercism.io/getting-started-with-cpp.html
I have a series of boost unit tests that check whether the correct message is returned when given an input. 我进行了一系列的增强单元测试,这些测试可以检查在输入时是否返回了正确的消息。 Most of the tests work, but strangely, some cause a build error.
大多数测试都能正常工作,但奇怪的是,有些会导致生成错误。
Error 1 error MSB3073: The command "setlocal
Debug\bob.exe
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
:VCEnd" exited with code 201. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets 134 5 bob
//bob.h //bob.h
#ifndef BOB_H
#define BOB_H
#include <istream>
class bob
{
public:
static char* hey(char*);
};
#endif
//bob.cpp //bob.cpp
#include "bob.h"
char* bob::hey(char * msg)
{
//if (!msg){return "";}
int msgLength = strlen(msg);
switch (msg[msgLength-1])
{
case '?':
return "Sure.";
break;
case '!':
return "Whoa, chill out!";
break;
case ' ':
case '\0':
return "Fine. Be that way!";
default:
break;
}
return "Whatever.";
}
//bob_test.cpp //bob_test.cpp
#include "bob.h"
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(stating_something)
{
BOOST_REQUIRE_EQUAL("Whatever.", bob::hey("Tom-ay-to, tom-aaaah-to."));
}
#if defined(EXERCISM_RUN_ALL_TESTS)
BOOST_AUTO_TEST_CASE(shouting)
{
BOOST_REQUIRE_EQUAL("Whoa, chill out!", bob::hey("WATCH OUT!"));
}
BOOST_AUTO_TEST_CASE(asking_a_question)
{
BOOST_REQUIRE_EQUAL("Sure.", bob::hey("Does this cryogenic chamber make me look fat?"));
}
/////////////This test causes the error
//BOOST_AUTO_TEST_CASE(talking_forcefully)
//{
// BOOST_REQUIRE_EQUAL("Whatever.", bob::hey("Let's go make out behind the gym!"));
//}
It looks like boost tests are working like they should. 看来增强测试正在按预期方式工作。 I needed to check the output window rather than look at build errors.
我需要检查输出窗口,而不是查看构建错误。
1>------ Build started: Project: bob, Configuration: Debug Win32 ------
1> bob_test.cpp
1> bob.vcxproj -> C:\exercism\cpp\build\Debug\bob.exe
1> Running 13 test cases...
1> C:/exercism/cpp/bob/bob_test.cpp(24): fatal error in "talking_forcefully": critical check "Whatever." == bob::hey("Let's go make out behind the gym!") failed [Whatever. != Whoa, chill out!]
1>
1> *** 1 failure detected in test suite "Master Test Suite"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.