libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
socket_client.cpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright © 2015 by J.M.McGuiness, coder@hussar.me.uk
3 **
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Lesser General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2.1 of the License, or (at your option) any later version.
8 **
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public
15 ** License along with this library; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 #include "stdafx.h"
20 
21 #define BOOST_TEST_MODULE libjmmcg_tests
22 #include <boost/test/included/unit_test.hpp>
23 
24 #include <boost/mpl/list.hpp>
25 
26 #include "core/socket_client_manager.hpp"
27 
28 using namespace libjmmcg;
29 
30 const boost::asio::ip::address localhost(boost::asio::ip::address_v4::loopback());
31 const unsigned short unused_port=12345u;
32 const unsigned short timeout=5; // In seconds.
33 
34 struct just_connect {
35  template<class Fn>
36  void operator()(Fn const &f) const {
37  const boost::asio::ip::tcp::endpoint endpoint(localhost, unused_port);
38  f(endpoint);
39  }
40 };
41 
42 struct message1 {
43  const char c[46]="The quick brown fox jumps over the lazy dog.";
44 };
45 
46 using lock_t=ppd::api_lock_traits<ppd::generic_traits::api_type::no_api, ppd::sequential_mode>::critical_section_type::lock_type;
47 
48 typedef boost::mpl::list<
52 
53 BOOST_AUTO_TEST_SUITE(socket_tests)
54 
55 BOOST_AUTO_TEST_SUITE(client)
56 
57 BOOST_AUTO_TEST_CASE_TEMPLATE(ctor, client_t, client_types) {
58  just_connect conn_pol;
59  BOOST_CHECK_THROW(
60  client_t skt(
61  sizeof(message1),
62  sizeof(message1),
63  timeout,
64  client_t::socket_t::socket_priority::low,
65  0,
66  conn_pol
67  ),
68  std::runtime_error
69  );
70 }
71 
72 BOOST_AUTO_TEST_SUITE_END()
73 
74 BOOST_AUTO_TEST_SUITE_END()