Boost logo

Boost Testing :

Subject: [Boost-testing] How to test callbacks / non-blocking calls?
From: ariasgore_at_[hidden]
Date: 2009-06-18 04:35:00


Hello,

I am testing some sort of socket connection where I have async callbacks which are of course non-blocking calls.
How can Boost::Test provide some testing facilities for that?

Here is a very simple example:

void mmyFunc(const char * text)
{
  // compare
}
BOOST_AUTO_TEST_CASE(foo)
{
  mocksocket m;
  MySocket my(1000); // listen on port 1000
  my.callback(myFunc); // register callback
  m.send("foo");

  BOOST_CHECK_??
  // test case ended
}

So my test cannot be executed at once in the case since the callback most probably fires too late. What are workarrounds for such scenarios?

Thank you
Sam

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

Boost-testing list run by mbergal at meta-comm.com