Ошибка cmake при сборке модульных тестов Boost

Я работаю над этим учебником, используя VS2012 в проекте c ++, созданном cmake 3.0.2.
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

Решение

Похоже, буст-тесты работают так, как должны. Мне нужно было проверить окно вывода, а не смотреть на ошибки сборки.

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"
0

Другие решения


По вопросам рекламы ammmcru@yandex.ru
Adblock
detector