2014-09-24 35 views
0

我正在通過本教程,在cmake 3.0.2生成的c + +項目上使用VS2012。 http://help.exercism.io/getting-started-with-cpp.htmlcmake錯誤,當建立提升單元測試

我有一系列的增強單元測試,檢查給定輸入時是否返回正確的消息。大部分測試都能正常工作,但奇怪的是,有些會導致構建錯誤。

enter image description here

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

它看起來像增強測試正在像他們應該的工作。我需要檢查輸出窗口而不是看構建錯誤。

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"