我正在使用VS2012对cmake 3.0.2生成的c ++项目进行本教程。 http://help.exercism.io/getting-started-with-cpp.html
我有一系列的升压单元测试,用于检查在给定输入时是否返回正确的消息。大多数测试都有效,但奇怪的是,有些测试会导致构建错误。
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
#ifndef BOB_H
#define BOB_H
#include <istream>
class bob
{
public:
static char* hey(char*);
};
#endif
// 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
#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!"));
//}
答案 0 :(得分:0)
看起来加速测试正如他们应该的那样工作。我需要检查输出窗口而不是查看构建错误。
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"