0

I'm working through this tutorial, using VS2012 on a c++ project generated by cmake 3.0.2. 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.

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!"));
//}
maogenc
  • 203
  • 7
  • 13

1 Answers1

0

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"
maogenc
  • 203
  • 7
  • 13