|
Boost Users : |
Subject: Re: [Boost-users] [Boost.Test + Turtle] Suggestion how to test async events.
From: Mathieu Champlon (m.champlon_at_[hidden])
Date: 2013-04-08 12:43:45
On 08/04/2013 16:32, Daniele Barzotti wrote:
> (...)
>
> Now, I have to test if into the ServerHandler::OnMsgMethodConnect() the
> argument args.msg (which is a message class) has the correct values.
>
> EG. if (msg.station_type() == EStationType::ST_CLIENT) => OK
>
> Which is the correct way to do it?
>
> Regards,
> Daniele.
Hi Daniele,
Turtle is not a boost component, so you might want to create a ticket
for support directly to the project (see
http://sourceforge.net/projects/turtle/support/).
A 'with' takes a constraint which general form is a functor testing the
received argument (see
http://turtle.sourceforge.net/turtle/customisation.html#turtle.customisation.constraints/).
The simplest solution for your problem would be a free function :
bool CheckArgs( TArgs& args )
{
return args.msg.station_type() == EStationType::ST_CLIENT;
}
with the expectation being :
MOCK_EXPECT( mockSvr.OnMsgMethodConnect ).once().with( mock::any,
&CheckArgs );
Of course this will quickly become tedious if you write several tests
checking various values, and you might want to factorize things a bit.
If you need more information, just create a support ticket and I will be
happy to help !
Cheers,
MAT.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net