Hi,
I'm writing a simple console application which use boost test and turtle library
All the code is:
#include "stdafx.h" #include "Logger.h" #include "SessionFactory.h" #include "EuroSDK/protocols/IMessage.h" #include "EuroSDK/protocols/IMessageDispatcher.h" #include "EuroSDK/protocols/MessageHandler.h" #include "EuroSDK/protocols/Session.h" #include "EuroSDK/protocols/ISessionFactory.h" #include "EuroSDK/protocols/eurosvr/NetMessageDispatcher.h" #include "EuroSDK/protocols/eurosvr/EuroSvrMessages.h" using namespace std; #define BOOST_TEST_DYN_LINK #ifdef STAND_ALONE_TEST # define BOOST_TEST_MODULE EurocomServerTest Test #endif #include <boost/test/unit_test.hpp> #include <boost/lambda/lambda.hpp> #include <boost/thread.hpp> #include <turtle/mock.hpp> class ClientHandler : public MessageEventHandler { public: ClientHandler() { // Register the messages I want to manage this->RegisterMsg(E_MSG_EVENT_CONNECT, Poco::delegate(this, &ClientHandler::OnMsgEventConnect)); } // Messages Handlers void OnMsgEventConnect(const void* pSender, TArgs& args) { cout << "ClientHandler receive MSG_EVENT_CONNECT" << endl; MSG_EVENT_CONNECT& msg = RetrieveMessage<MSG_EVENT_CONNECT>(args.msg); }; }; bool Check_ClientOnMsgEventConnect(MessageEventHandler::TArgs& args) { MSG_EVENT_CONNECT& msg = RetrieveMessage<MSG_EVENT_CONNECT>(args.msg); return (msg.header().status() == 0); } template< typename M > void wait(bool& condition, M method, int timeout = 100, int sleep = 100) { while (!condition && timeout > 0) { --timeout; boost::this_thread::sleep(boost::posix_time::milliseconds(sleep)); method(); }; } // declare a 'mockClientHandler' class implementing 'ClientHandler' MOCK_BASE_CLASS(mockClientHandler, ClientHandler) { // implement the 'OnMsgEventConnect' method from 'ClientHandler' (taking 2 arguments) MOCK_METHOD(OnMsgEventConnect, 2); }; BOOST_AUTO_TEST_SUITE(EurocomServerTest_TestSuite) BOOST_AUTO_TEST_CASE(EurocomServerTest) { bool done = false; Logger& consoleLogger = CreateLogger(); mockClientHandler mockClient; SessionFactory* sf = new SessionFactory(mockClient); IMessageFactory* mf = new PBMessageFactory(); NetMessageDispatcher* client = new NetMessageDispatcher(sf, mf, consoleLogger, E_DISP_CLIENT); BOOST_CHECK(client->Init("LOCALHOST", "TestClient") == EC_NO_ERRORS); BOOST_CHECK(client->Connect(8000, "127.0.0.1") == EC_NO_ERRORS); MSG_METHOD_CONNECT msg; msg.mutable_header()->set_transactionid(0); msg.set_station_id("ID_TestClient"); msg.set_station_alias("TestClient"); msg.set_mode(ST_ALL_MESSAGES); msg.set_user_name("admin"); msg.set_user_pwd("admin"); client->SendMessage(EuroSvrMessage<MSG_METHOD_CONNECT>(msg)); cout << "Waiting message.." << endl; MOCK_EXPECT(mockClient.OnMsgEventConnect) .once() .with(mock::any, &Check_ClientOnMsgEventConnect) .calls(boost::lambda::var(done) = true); wait(done, boost::bind(&ClientHandler::OnMsgEventConnect, &mockClient)); } BOOST_AUTO_TEST_SUITE_END()
If I comment the last line (when I call the wait function), it compiles with no errors, otherwise it give me:
1>d:\lib\boost_1_55_0\boost\bind\mem_fn.hpp(318): warning C4180: qualifier applied to function type has no meaning; ignored 1> d:\lib\boost_1_55_0\boost\bind\bind_template.hpp(344) : see reference to class template instantiation 'boost::_mfi::dm<void (const void *,EurocomSDK::Protocols::MessageEventHandler::TArgs &),ClientHandler>' being compiled 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(341,5): error MSB6006: "CL.exe" exited with code 1.
where the line 341, 5 is:
<CL Condition="'%(ClCompile.PrecompiledHeader)' != 'Create' and '%(ClCompile.ExcludedFromBuild)'!='true' and '%(ClCompile.CompilerIteration)' == '' and @(ClCompile) != ''"
Someone known what happen?
Regards.