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.
24 \brief ServerSocketHandle unit tests */
26 //#include "ServerSocketHandle.test.hh"
27 //#include "ServerSocketHandle.test.ih"
30 #include "ServerSocketHandle.hh"
31 #include "ClientSocketHandle.hh"
32 #include "SocketProtocol.test.hh"
33 #include "AddressingPolicy.hh"
35 #include <senf/Utils/auto_unit_test.hh>
36 #include <boost/test/test_tools.hpp>
39 ///////////////////////////////cc.p////////////////////////////////////////
44 : public senf::ServerSocketHandle<senf::test::SomeSocketProtocol::Policy>
48 : senf::ServerSocketHandle<senf::test::SomeSocketProtocol::Policy>(
49 std::auto_ptr<senf::SocketBody>(
50 new senf::ProtocolSocketBody<senf::test::SomeSocketProtocol>(true)))
56 SENF_AUTO_UNIT_TEST(serverSocketHandle)
58 typedef senf::MakeSocketPolicy<
59 senf::test::SomeFramingPolicy,
60 senf::test::SomeReadPolicy,
61 senf::test::SomeWritePolicy
62 >::policy OtherSocketPolicy;
63 typedef senf::SocketHandle<OtherSocketPolicy> OtherSocketHandle;
66 OtherSocketHandle osh (myh);
69 typedef senf::ServerSocketHandle<senf::test::SomeSocketProtocol::Policy> SomeSocketHandle;
70 SomeSocketHandle ssh = senf::static_socket_cast<SomeSocketHandle>(osh);
72 typedef senf::ServerSocketHandle<senf::MakeSocketPolicy<
74 senf::NoAddressingPolicy
75 >::policy> SomeOtherSocketHandle;
76 typedef senf::ClientSocketHandle<OtherSocketPolicy> OtherClientHandle;
78 SENF_CHECK_NO_THROW( senf::dynamic_socket_cast<SomeSocketHandle>(osh) );
79 BOOST_CHECK_THROW( senf::dynamic_socket_cast<SomeOtherSocketHandle>(osh),
81 BOOST_CHECK_THROW( senf::dynamic_socket_cast<OtherClientHandle>(osh),
84 SENF_CHECK_NO_THROW( myh.bind(0) );
85 BOOST_CHECK_EQUAL( myh.local(), 2u );
88 MySocketHandle::ClientHandle client = myh.accept();
89 BOOST_CHECK_EQUAL( client.fd(), -1 );
95 ///////////////////////////////cc.e////////////////////////////////////////
102 // c-file-style: "senf"
103 // indent-tabs-mode: nil
104 // ispell-local-dictionary: "american"
105 // compile-command: "scons -u test"
106 // comment-column: 40