NetworkTesting.hpp
Go to the documentation of this file.
1 // @formatter:off
2 //
3 // Balau core C++ library
4 //
5 // Copyright (C) 2008 Bora Software (contact@borasoftware.com)
6 //
7 // Licensed under the Boost Software License - Version 1.0 - August 17th, 2003.
8 // See the LICENSE file for the full license text.
9 //
10 
16 
17 #ifndef COM_BORA_SOFTWARE__BALAU_TESTING_UTIL__NETWORK_TESTING
18 #define COM_BORA_SOFTWARE__BALAU_TESTING_UTIL__NETWORK_TESTING
19 
20 #include <functional>
21 
22 namespace Balau::Testing {
23 
27 struct NetworkTesting final {
42  static unsigned short initialiseWithFreeTcpPort(std::function<unsigned short ()> code, size_t attempts = 10);
43 
57  static unsigned short getFreeTcpPort(unsigned short start = 1025, unsigned short count = 65535);
58 
60 
61  NetworkTesting() = delete;
62  NetworkTesting(const NetworkTesting &) = delete;
63  NetworkTesting & operator = (const NetworkTesting &) = delete;
64 };
65 
66 } // namespace Balau::Testing
67 
68 #endif // COM_BORA_SOFTWARE__BALAU_TESTING_UTIL__NETWORK_TESTING
Utilities for testing network functionality.
Definition: NetworkTesting.hpp:27
static unsigned short initialiseWithFreeTcpPort(std::function< unsigned short()> code, size_t attempts=10)
Repeatedly execute the supplied code until there is no network exception due to an in use port...
The test runner and test assertion functions.
Definition: Assertions.hpp:23
static unsigned short getFreeTcpPort(unsigned short start=1025, unsigned short count=65535)
Get a TCP port number that is free at the time of the call.