1 /* $Id: test_pipe.cpp,v 1.2 2005-11-07 21:57:10 adam Exp $
2 Copyright (c) 2005, Index Data.
9 #include <yaz++/socket-manager.h>
17 #define BOOST_AUTO_TEST_MAIN
18 #include <boost/test/auto_unit_test.hpp>
20 using namespace boost::unit_test;
22 class Timer : public yazpp_1::ISocketObserver {
24 yazpp_1::ISocketObservable *m_obs;
28 Timer(yazpp_1::ISocketObservable *obs, int duration);
29 void socketNotify(int event);
30 bool timeout() { return m_timeout; };
34 Timer::Timer(yazpp_1::ISocketObservable *obs,
36 m_obs(obs), m_pipe(0), m_timeout(false)
38 obs->addObserver(m_pipe.read_fd(), this);
39 obs->maskObserver(this, yazpp_1::SOCKET_OBSERVE_READ);
40 obs->timeoutObserver(this, duration);
43 void Timer::socketNotify(int event)
46 m_obs->deleteObserver(this);
49 BOOST_AUTO_TEST_CASE( test_pipe_1 )
51 yazpp_1::SocketManager mySocketManager;
55 Timer t(&mySocketManager, 0);
57 while (mySocketManager.processEvent() > 0)
60 BOOST_CHECK(t.timeout());
66 * indent-tabs-mode: nil
67 * c-file-style: "stroustrup"
69 * vim: shiftwidth=4 tabstop=8 expandtab