Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit623cd33

Browse files
committed
Merge pull requestcpp-netlib#197 from deanberris/gtest-migration
Migrate all tests to gtest
2 parents7b51f5c +78de299 commit623cd33

26 files changed

+401
-1245
lines changed

‎CMakeLists.txt‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ else()
2323
set(Boost_USE_STATIC_LIBSON)
2424
endif()
2525
set(Boost_USE_MULTITHREADEDON)
26-
if(CPP-NETLIB_BUILD_TESTS)
27-
set(Boost_COMPONENTS unit_test_frameworksystemregex date_time filesystem program_options )
28-
else()
29-
set(Boost_COMPONENTSsystemregex date_time filesystem program_options )
30-
endif()
26+
set(Boost_COMPONENTSsystemregex date_time filesystem program_options )
3127
find_package( Boost 1.51 REQUIRED${Boost_COMPONENTS} )
3228
find_package( OpenSSL )
3329
find_package( Threads )
@@ -47,15 +43,15 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
4743
INCLUDE(CheckCXXCompilerFlag)
4844
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
4945
if (HAVE_STD11)
50-
set(CMAKE_CXX_FLAGS -std=c++11)
46+
set(CMAKE_CXX_FLAGS -std=c++11 -Wall)
5147
else()
5248
message(FATAL_ERROR"No advanced standard C++ support (-std=c++11 not defined).")
5349
endif()
5450
elseif(${CMAKE_CXX_COMPILER_ID}MATCHES Clang)
5551
INCLUDE(CheckCXXCompilerFlag)
5652
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
5753
if (HAVE_STD11)
58-
set(CMAKE_CXX_FLAGS"-std=c++11 -stdlib=libc++")
54+
set(CMAKE_CXX_FLAGS"-std=c++11 -stdlib=libc++ -Wall")
5955
set(CMAKE_CXX_LINK_FLAGS"-std=c++11 -stdlib=libc++")
6056
else()
6157
message(FATAL_ERROR"No C++11 support for Clang version. Please upgrade Clang to a version supporting C++11.")

‎concurrency/test/CMakeLists.txt‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@
33
# (See accompanying file LICENSE_1_0.txt or copy at
44
# http://www.boost.org/LICENSE_1_0.txt)
55

6-
include_directories(${CPP-NETLIB_SOURCE_DIR}/concurrency/src)
7-
8-
if (${CMAKE_CXX_COMPILER_ID}MATCHES GNU)
9-
set(CPP-NETLIB_CXXFLAGS"-Wall -std=c++11")
10-
elseif (${CMAKE_CXX_COMPILER_ID}MATCHES Clang)
11-
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
12-
set(CPP-NETLIB_CXXFLAGS"-Wall -std=c++11 -stdlib=libc++")
13-
set(CPP-NETLIB_CXXFLAGS"-Wall -std=c++11 -stdlib=libc++")
14-
endif()
6+
include_directories(${CPP-NETLIB_SOURCE_DIR}/concurrency/src
7+
${GTEST_INCLUDE_DIRS}
8+
)
159

1610
set_source_files_properties(thread_pool_test.cpp
1711
PROPERTIESCOMPILE_FLAGS"-Wall")
1812
add_executable(cpp-netlib-thread_pool_test thread_pool_test.cpp)
1913
target_link_libraries(cpp-netlib-thread_pool_test
2014
cppnetlib-concurrency
2115
${Boost_LIBRARIES}
16+
${GTEST_BOTH_LIBRARIES}
2217
${CMAKE_THREAD_LIBS_INIT})
2318
set_target_properties(cpp-netlib-thread_pool_test
2419
PROPERTIESRUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11

2-
// Copyright 2010Dean Michael Berris.
2+
// Copyright 2010, 2012Dean Michael Berris <dberris@google.com>
33
// Copyright 2012 Google, Inc.
44
// Copyright (c) Glyn Matthews 2012.
55
// Distributed under the Boost Software License, Version 1.0.
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
88

9-
#ifdef BUILD_SHARED_LIBS
10-
#defineBOOST_TEST_DYN_LINK
11-
#endif
12-
#defineBOOST_TEST_MODULE thread pool test
13-
#include<boost/config/warning_disable.hpp>
14-
#include<boost/test/unit_test.hpp>
9+
#include<gtest/gtest.h>
1510
#include<network/concurrency/thread_pool.hpp>
1611
#include<boost/bind.hpp>
1712

@@ -25,9 +20,9 @@ using network::concurrency::thread_pool;
2520
// syntactically.
2621
//
2722

28-
BOOST_AUTO_TEST_CASE( default_constructor) {
23+
TEST(concurrency_test, default_constructor) {
2924
thread_pool pool;
30-
BOOST_CHECK_EQUAL(pool.thread_count(),std::size_t(1));
25+
ASSERT_EQ(pool.thread_count(),std::size_t(1));
3126
}
3227

3328
structfoo {
@@ -42,13 +37,13 @@ struct foo {
4237
int val_;
4338
};
4439

45-
BOOST_AUTO_TEST_CASE( post_work) {
40+
TEST(concurrency_test, post_work) {
4641
foo instance;
4742
{
4843
thread_pool pool;
49-
BOOST_CHECK_NO_THROW(pool.post(boost::bind(&foo::bar, &instance,1)));
50-
BOOST_CHECK_NO_THROW(pool.post(boost::bind(&foo::bar, &instance,2)));
44+
ASSERT_NO_THROW(pool.post(boost::bind(&foo::bar, &instance,1)));
45+
ASSERT_NO_THROW(pool.post(boost::bind(&foo::bar, &instance,2)));
5146
// require that pool is destroyed here, RAII baby
5247
}
53-
BOOST_CHECK_EQUAL(instance.val(),3);
48+
ASSERT_EQ(instance.val(),3);
5449
}

‎http/src/network/protocol/http/request/request_base.ipp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#defineNETWORK_RPTOCOL_HTTP_REQUEST_BASE_IPP_20111102
99

1010
#include<network/protocol/http/request/request_base.hpp>
11+
#include<vector>
1112
#include<thread>
1213
#include<cstring>
1314

‎http/test/CMakeLists.txt‎

Lines changed: 62 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ include_directories(
88
${CPP-NETLIB_SOURCE_DIR}/message/src
99
${CPP-NETLIB_SOURCE_DIR}/logging/src
1010
${CPP-NETLIB_SOURCE_DIR}/http/src
11+
${GTEST_INCLUDE_DIRS}
1112
${CPP-NETLIB_SOURCE_DIR})
1213

1314
if (OPENSSL_FOUND)
1415
include_directories(${OPENSSL_INCLUDE_DIR} )
15-
add_definitions(-DBOOST_NETWORK_ENABLE_HTTPS)
16+
add_definitions(-DNETWORK_ENABLE_HTTPS)
1617
endif()
1718

1819
if(NOT CPP-NETLIB_DISABLE_LOGGING )
@@ -23,13 +24,13 @@ endif()
2324
# if not then it will be empty
2425
set( CPP-NETLIB_LOGGING_LIB cppnetlib-logging )
2526

26-
if (Boost_FOUND)
27+
if (CPP-NETLIB_BUILD_TESTS)
2728
# These are the internal (simple) tests.
28-
set (MESSAGE_TESTS
29+
set (MESSAGE_TESTS
2930
request_base_test
3031
request_test
31-
request_linearize_test
3232
response_test
33+
response_incremental_parser_test
3334
)
3435
foreach (test${MESSAGE_TESTS} )
3536
if (${CMAKE_CXX_COMPILER_ID}MATCHES GNU)
@@ -47,6 +48,7 @@ if (Boost_FOUND)
4748
)
4849
target_link_libraries(cpp-netlib-http-${test}
4950
${Boost_LIBRARIES}
51+
${GTEST_BOTH_LIBRARIES}
5052
${ICU_LIBRARIES}${ICU_I18N_LIBRARIES}
5153
${CMAKE_THREAD_LIBS_INIT}
5254
cppnetlib-message
@@ -62,69 +64,62 @@ if (Boost_FOUND)
6264
${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})
6365
endforeach(test)
6466

65-
set ( TESTS
66-
client_constructor_test
67-
client_get_test
68-
client_get_different_port_test
69-
client_get_timeout_test
70-
client_get_streaming_test
71-
)
72-
foreach (test${TESTS} )
73-
if (${CMAKE_CXX_COMPILER_ID}MATCHES GNU)
74-
set_source_files_properties(${test}.cpp
75-
PROPERTIESCOMPILE_FLAGS"-Wall")
76-
endif()
77-
add_executable(cpp-netlib-http-${test}${test}.cpp)
78-
target_link_libraries(cpp-netlib-http-${test}
79-
${Boost_LIBRARIES}
80-
${ICU_LIBRARIES}${ICU_I18N_LIBRARIES}
81-
${CMAKE_THREAD_LIBS_INIT}
82-
cppnetlib-constants
83-
cppnetlib-uri
84-
cppnetlib-message
85-
cppnetlib-message-wrappers
86-
cppnetlib-message-directives
87-
${CPP-NETLIB_LOGGING_LIB}
88-
cppnetlib-http-message
89-
cppnetlib-http-message-wrappers
90-
cppnetlib-http-client
91-
cppnetlib-http-client-connections)
92-
if (OPENSSL_FOUND)
93-
target_link_libraries(cpp-netlib-http-${test}${OPENSSL_LIBRARIES})
94-
endif()
95-
set_target_properties(cpp-netlib-http-${test}
96-
PROPERTIESRUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
97-
add_test(cpp-netlib-http-${test}
98-
${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})
99-
endforeach (test)
67+
if (${CMAKE_CXX_COMPILER_ID}MATCHES GNU)
68+
set_source_files_properties(client_test.cpp
69+
PROPERTIESCOMPILE_FLAGS"-Wall")
70+
endif()
71+
add_executable(cpp-netlib-http-client_test client_test.cpp)
72+
target_link_libraries(cpp-netlib-http-client_test
73+
${Boost_LIBRARIES}
74+
${GTEST_BOTH_LIBRARIES}
75+
${ICU_LIBRARIES}${ICU_I18N_LIBRARIES}
76+
${CMAKE_THREAD_LIBS_INIT}
77+
cppnetlib-constants
78+
cppnetlib-uri
79+
cppnetlib-message
80+
cppnetlib-message-wrappers
81+
cppnetlib-message-directives
82+
${CPP-NETLIB_LOGGING_LIB}
83+
cppnetlib-http-message
84+
cppnetlib-http-message-wrappers
85+
cppnetlib-http-client
86+
cppnetlib-http-client-connections)
87+
if (OPENSSL_FOUND)
88+
target_link_libraries(cpp-netlib-http-client_test${OPENSSL_LIBRARIES})
89+
endif()
90+
set_target_properties(cpp-netlib-http-client_test
91+
PROPERTIESRUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
92+
add_test(cpp-netlib-http-client_test
93+
${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})
10094

101-
#set ( SERVER_API_TESTS
102-
# server_constructor_test
103-
# server_async_run_stop_concurrency
104-
# )
105-
#foreach ( test ${SERVER_API_TESTS} )
106-
# if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
107-
# set_source_files_properties(${test}.cpp
108-
# PROPERTIES COMPILE_FLAGS "-Wall")
109-
# endif()
110-
# add_executable(cpp-netlib-http-${test} ${test}.cpp)
111-
# target_link_libraries(cpp-netlib-http-${test}
112-
# ${Boost_LIBRARIES}
113-
# ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
114-
# ${CMAKE_THREAD_LIBS_INIT}
115-
# cppnetlib-constants
116-
# cppnetlib-uri
117-
# cppnetlib-message
118-
# cppnetlib-message-wrappers
119-
# cppnetlib-http-message
120-
# cppnetlib-http-server
121-
# cppnetlib-http-server-parsers
122-
# cppnetlib-utils-thread_pool
123-
# )
124-
# set_target_properties(cpp-netlib-http-${test}
125-
# PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
126-
# add_test(cpp-netlib-http-${test}
127-
# ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})
128-
#endforeach (test)
95+
# set ( SERVER_API_TESTS
96+
# server_constructor_test
97+
# server_async_run_stop_concurrency
98+
# )
99+
# foreach ( test ${SERVER_API_TESTS} )
100+
# if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
101+
# set_source_files_properties(${test}.cpp
102+
# PROPERTIES COMPILE_FLAGS "-Wall")
103+
# endif()
104+
# add_executable(cpp-netlib-http-${test} ${test}.cpp)
105+
# target_link_libraries(cpp-netlib-http-${test}
106+
# ${Boost_LIBRARIES}
107+
# ${GTEST_BOTH_LIBRARIES}
108+
# ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
109+
# ${CMAKE_THREAD_LIBS_INIT}
110+
# cppnetlib-constants
111+
# cppnetlib-uri
112+
# cppnetlib-message
113+
# cppnetlib-message-wrappers
114+
# cppnetlib-http-message
115+
# cppnetlib-http-server
116+
# cppnetlib-http-server-parsers
117+
# cppnetlib-utils-thread_pool
118+
# )
119+
# set_target_properties(cpp-netlib-http-${test}
120+
# PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/tests)
121+
# add_test(cpp-netlib-http-${test}
122+
# ${CPP-NETLIB_BINARY_DIR}/tests/cpp-netlib-http-${test})
123+
# endforeach (test)
129124

130125
endif()

‎http/test/client_constructor_test.cpp‎

Lines changed: 0 additions & 32 deletions
This file was deleted.

‎http/test/client_get_different_port_test.cpp‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎http/test/client_get_streaming_test.cpp‎

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp