4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 //#include "ServerSocketHandle.test.hh"
26 //#include "ServerSocketHandle.test.ih"
29 #include "ServerSocketHandle.hh"
30 #include "ClientSocketHandle.hh"
31 #include "SocketProtocol.test.hh"
32 #include "AddressingPolicy.hh"
34 #include "../Utils/auto_unit_test.hh"
35 #include <boost/test/test_tools.hpp>
38 ///////////////////////////////cc.p////////////////////////////////////////
43 : public senf::ServerSocketHandle<senf::test::SomeProtocol::Policy>
47 : senf::ServerSocketHandle<senf::test::SomeProtocol::Policy>(
48 std::auto_ptr<senf::SocketBody>(
49 new senf::ProtocolSocketBody<senf::test::SomeProtocol>(true)))
55 BOOST_AUTO_UNIT_TEST(serverSocketHandle)
57 typedef senf::MakeSocketPolicy<
58 senf::test::SomeFramingPolicy,
59 senf::test::SomeReadPolicy,
60 senf::test::SomeWritePolicy
61 >::policy OtherSocketPolicy;
62 typedef senf::SocketHandle<OtherSocketPolicy> OtherSocketHandle;
65 OtherSocketHandle osh (myh);
68 typedef senf::ServerSocketHandle<senf::test::SomeProtocol::Policy> SomeSocketHandle;
69 SomeSocketHandle ssh = senf::static_socket_cast<SomeSocketHandle>(osh);
71 typedef senf::ServerSocketHandle<senf::MakeSocketPolicy<
73 senf::NoAddressingPolicy
74 >::policy> SomeOtherSocketHandle;
75 typedef senf::ClientSocketHandle<OtherSocketPolicy> OtherClientHandle;
77 BOOST_CHECK_NO_THROW( senf::dynamic_socket_cast<SomeSocketHandle>(osh) );
78 BOOST_CHECK_THROW( senf::dynamic_socket_cast<SomeOtherSocketHandle>(osh),
80 BOOST_CHECK_THROW( senf::dynamic_socket_cast<OtherClientHandle>(osh),
83 BOOST_CHECK_NO_THROW( myh.bind(0) );
84 BOOST_CHECK_EQUAL( myh.local(), 2u );
87 MySocketHandle::ClientSocketHandle client = myh.accept();
88 BOOST_CHECK_EQUAL( client.fd(), -1 );
94 ///////////////////////////////cc.e////////////////////////////////////////
101 // c-file-style: "senf"
102 // indent-tabs-mode: nil
103 // ispell-local-dictionary: "american"
104 // compile-command: "scons -u test"
105 // comment-column: 40