1 /* $Id: test_pipe.cpp,v 1.4 2005-12-02 12:21:07 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(9122), 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_UNIT_TEST( test_pipe_1 )
51 yazpp_1::SocketManager mySocketManager;
53 Timer t(&mySocketManager, 0);
55 while (mySocketManager.processEvent() > 0)
58 BOOST_CHECK(t.timeout());
64 * indent-tabs-mode: nil
65 * c-file-style: "stroustrup"
67 * vim: shiftwidth=4 tabstop=8 expandtab