Skip to content

Commit 15484ba

Browse files
committed
Adding Server API tests.
1 parent 9e57066 commit 15484ba

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

libs/network/test/http/CMakeLists.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ if (Boost_FOUND)
4141
${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})
4242
endforeach (test)
4343

44+
set ( SERVER_API_TESTS
45+
server_constructor_test
46+
)
47+
foreach ( test ${SERVER_API_TESTS} )
48+
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
49+
set_source_files_properties(${test}.cpp
50+
PROPERTIES COMPILE_FLAGS "-Wall")
51+
endif()
52+
add_executable(cpp-netlib-http-${test} ${test}.cpp)
53+
add_dependencies(cpp-netlib-http-${test} cppnetlib-server-parsers)
54+
target_link_libraries(cpp-netlib-http-${test} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-server-parsers)
55+
set_target_properties(cpp-netlib-http-${test}
56+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
57+
add_test(cpp-netlib-http-${test}
58+
${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})
59+
endforeach (test)
60+
4461
set ( SERVER_TESTS
4562
server_hello_world
4663
server_async
@@ -58,7 +75,7 @@ if (Boost_FOUND)
5875
${CPP-NETLIB_BINARY_DIR}/tests)
5976
add_test(cpp-netlib-${test}
6077
python
61-
${CPP-NETLIB_SOURCE_DIR}/libs/network/httplib_acceptance.py
78+
${CPP-NETLIB_SOURCE_DIR}/libs/network/test/httplib_acceptance.py
6279
${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test}
6380
${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test}.passed)
6481
endforeach (test)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
// Copyright 2010 Dean Michael Berris.
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// (See accompanying file LICENSE_1_0.txt or copy at
5+
// http://www.boost.org/LICENSE_1_0.txt)
6+
7+
#define BOOST_TEST_MODULE HTTP Server Construtor Tests
8+
9+
#include <boost/network/include/http/server.hpp>
10+
#include <boost/test/unit_test.hpp>
11+
12+
namespace http = boost::network::http;
13+
namespace util = boost::network::utils;
14+
15+
struct dummy_sync_handler;
16+
struct dummy_async_handler;
17+
typedef http::server<dummy_sync_handler> sync_server;
18+
typedef http::async_server<dummy_async_handler> async_server;
19+
20+
struct dummy_sync_handler {
21+
void operator()(sync_server::request const & req,
22+
sync_server::response & res) {
23+
// Really, this is just for testing purposes
24+
}
25+
26+
void log(char const *) {
27+
}
28+
};
29+
30+
struct dummy_async_handler {
31+
void operator()(async_server::request const & req,
32+
async_server::connection_ptr conn) {
33+
// Really, this is just for testing purposes
34+
}
35+
};
36+
37+
BOOST_AUTO_TEST_CASE(minimal_constructor) {
38+
dummy_sync_handler sync_handler;
39+
dummy_async_handler async_handler;
40+
util::thread_pool pool;
41+
42+
BOOST_CHECK_NO_THROW(sync_server sync_instance("127.0.0.1", "80", sync_handler) );
43+
BOOST_CHECK_NO_THROW(async_server async_instance("127.0.0.1", "80", async_handler, pool) );
44+
}
45+
46+
BOOST_AUTO_TEST_CASE(with_io_service_parameter) {
47+
}
48+
49+
BOOST_AUTO_TEST_CASE(with_socket_options_parameter) {
50+
}

0 commit comments

Comments
 (0)