summarylogtreecommitdiffstats
path: root/boost1_600tests.patch
blob: be744cbd1fc7f9a67eaf03b5ba94f3666002b0d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
From ff29581baa74dbc6ce1923e1352f4fd6d423a67d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20L=C3=B6f?= <andreas@alternating.net>
Date: Mon, 28 Dec 2015 22:58:50 +1300
Subject: [PATCH] Fix bug #24234: Add Boost 1.60.0 support to unit tests

The unit test part in boost has changed a few header files and
function signatures between previous versions and 1.60.0. These
changes adds a version check and two different versions of the
affected code, as well as introducing semicolons after the global text
fixtures (which doesn't appear to do harm) but otherwise requires more
version checks.
---
 src/tests/main.cpp                     | 20 +++++++++++++++++-
 src/tests/test_map_location.cpp        |  4 ++--
 src/tests/test_mp_connect.cpp          |  4 ++--
 src/tests/utils/auto_parameterized.hpp | 38 +++++++++++++++++++++++++++++++---
 4 files changed, 58 insertions(+), 8 deletions(-)

diff --git a/src/tests/main.cpp b/src/tests/main.cpp
index fe5ed3f..10551c9 100644
--- a/src/tests/main.cpp
+++ b/src/tests/main.cpp
@@ -16,11 +16,19 @@
 
 
 #define BOOST_TEST_MODULE wesnoth unit tests master suite
+
+#include <boost/version.hpp>
+
 #include <boost/test/unit_test.hpp>
 #include <boost/test/unit_test_monitor.hpp>
+#if BOOST_VERSION >= 106000
+#include <boost/test/unit_test_parameters.hpp>
+#else
 #include <boost/test/detail/unit_test_parameters.hpp>
+#endif
 #include <boost/test/results_reporter.hpp>
 
+
 #include <fstream>
 
 #include "SDL.h"
@@ -80,6 +88,15 @@ struct wesnoth_global_fixture {
 
 
 		// Set more report as default
+#if BOOST_VERSION >= 106000
+		if (boost::unit_test::runtime_config::get<boost::unit_test::log_level>(boost::unit_test::runtime_config::LOG_LEVEL) == boost::unit_test::invalid_log_level)
+			boost::unit_test::unit_test_log.set_threshold_level( boost::unit_test::log_messages );
+		if (boost::unit_test::runtime_config::get<boost::unit_test::report_level>(boost::unit_test::runtime_config::REPORT_LEVEL) == boost::unit_test::INV_REPORT_LEVEL)
+			boost::unit_test::results_reporter::set_level(boost::unit_test::SHORT_REPORT);
+		boost::unit_test::unit_test_monitor.register_exception_translator<game::error>(&exception_translator_game);
+		boost::unit_test::unit_test_monitor.register_exception_translator<network::error>(&exception_translator_network);
+		boost::unit_test::unit_test_monitor.register_exception_translator<config::error>(&exception_translator_config);
+#else
 		if (boost::unit_test::runtime_config::log_level() == boost::unit_test::invalid_log_level)
 			boost::unit_test::unit_test_log.set_threshold_level( boost::unit_test::log_messages );
 		if (boost::unit_test::runtime_config::report_level() == boost::unit_test::INV_REPORT_LEVEL)
@@ -87,6 +104,7 @@ struct wesnoth_global_fixture {
 		boost::unit_test::unit_test_monitor.register_exception_translator<game::error>(&exception_translator_game);
 		boost::unit_test::unit_test_monitor.register_exception_translator<network::error>(&exception_translator_network);
 		boost::unit_test::unit_test_monitor.register_exception_translator<config::error>(&exception_translator_config);
+#endif
 	}
 	~wesnoth_global_fixture()
 	{
@@ -94,7 +112,7 @@ struct wesnoth_global_fixture {
 	}
 };
 
-BOOST_GLOBAL_FIXTURE(wesnoth_global_fixture)
+BOOST_GLOBAL_FIXTURE(wesnoth_global_fixture);
 
 /*
  * This is a main compilation unit for the test program.
diff --git a/src/tests/test_map_location.cpp b/src/tests/test_map_location.cpp
index ca644c1..1077b62 100644
--- a/src/tests/test_map_location.cpp
+++ b/src/tests/test_map_location.cpp
@@ -64,9 +64,9 @@ struct MLFixture
 	~MLFixture() {}
 };
 
-BOOST_GLOBAL_FIXTURE ( MLFixture )
+BOOST_GLOBAL_FIXTURE ( MLFixture );
 
-BOOST_AUTO_TEST_SUITE ( test_map_location )
+BOOST_AUTO_TEST_SUITE ( test_map_location );
 
 //#define MAP_LOCATION_GET_OUTPUT
 
diff --git a/src/tests/test_mp_connect.cpp b/src/tests/test_mp_connect.cpp
index 051f868..2b69aee 100644
--- a/src/tests/test_mp_connect.cpp
+++ b/src/tests/test_mp_connect.cpp
@@ -125,8 +125,8 @@ static ng::side_engine* create_side_engine(const config& defaults,
 
 /* Tests */
 
-BOOST_GLOBAL_FIXTURE( mp_connect_fixture )
-BOOST_AUTO_TEST_SUITE( mp_connect )
+BOOST_GLOBAL_FIXTURE( mp_connect_fixture );
+BOOST_AUTO_TEST_SUITE( mp_connect );
 
 
 BOOST_AUTO_TEST_CASE( flg_map_settings )
diff --git a/src/tests/utils/auto_parameterized.hpp b/src/tests/utils/auto_parameterized.hpp
index dd903cf..2a6705f 100644
--- a/src/tests/utils/auto_parameterized.hpp
+++ b/src/tests/utils/auto_parameterized.hpp
@@ -15,15 +15,46 @@
 #ifndef TESTS_UTILS_AUTO_PARAMETERIZED_HPP_INCLUDED
 #define TESTS_UTILS_AUTO_PARAMETERIZED_HPP_INCLUDED
 
+#include <boost/version.hpp>
+
 #include <boost/test/unit_test_suite.hpp>
 #include <boost/test/parameterized_test.hpp>
 
+#if BOOST_VERSION >= 106000
+#include <boost/test/tree/auto_registration.hpp>
+#endif
+
 namespace test_utils {
 
 #ifndef BOOST_AUTO_TU_REGISTRAR
 #define BOOST_AUTO_TU_REGISTRAR BOOST_AUTO_TC_REGISTRAR
 #endif
 
+#if BOOST_VERSION >= 106000
+#define WESNOTH_PARAMETERIZED_TEST_CASE( test_name, type_name, values, param_name )   \
+struct test_name : public BOOST_AUTO_TEST_CASE_FIXTURE                  \
+{ void test_method(const type_name&); };                                \
+\
+type_name* BOOST_JOIN(test_name, _begin) = &values[0];    \
+type_name* BOOST_JOIN(test_name, _end) = BOOST_JOIN(test_name, _begin) + (sizeof(values)/sizeof(values[0])); \
+static void BOOST_AUTO_TC_INVOKER( test_name )(const type_name& param_name ) \
+{ \
+	test_name t;                                                        \
+    t.test_method(param_name);       \
+}                                                                       \
+                                                                        \
+struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {};                         \
+                                                                        \
+BOOST_AUTO_TU_REGISTRAR( test_name )( \
+				     boost::unit_test::make_test_case(&BOOST_AUTO_TC_INVOKER( test_name ), \
+								      BOOST_TEST_STRINGIZE( test_name ), \
+								      BOOST_TEST_STRINGIZE(__FILE__), __LINE__, \
+								      BOOST_JOIN(test_name, _begin), BOOST_JOIN(test_name, _end)), \
+				     boost::unit_test::decorator::collector::instance()); \
+                                                                       \
+void test_name::test_method(const type_name& param_name)                \
+/**/
+#else
 #define WESNOTH_PARAMETERIZED_TEST_CASE( test_name, type_name, values, param_name )   \
 struct test_name : public BOOST_AUTO_TEST_CASE_FIXTURE                  \
 { void test_method(const type_name&); };                                \
@@ -39,12 +70,13 @@ static void BOOST_AUTO_TC_INVOKER( test_name )(const type_name& param_name ) \
 struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {};                         \
                                                                         \
 BOOST_AUTO_TU_REGISTRAR( test_name )( \
-		boost::unit_test::make_test_case(&BOOST_AUTO_TC_INVOKER( test_name ),      \
-			BOOST_TEST_STRINGIZE( test_name ),\
-			BOOST_JOIN(test_name, _begin), BOOST_JOIN(test_name, _end)));		\
+				     boost::unit_test::make_test_case(&BOOST_AUTO_TC_INVOKER( test_name ), \
+								      BOOST_TEST_STRINGIZE( test_name ), \
+								      BOOST_JOIN(test_name, _begin), BOOST_JOIN(test_name, _end))); \
                                                                        \
 void test_name::test_method(const type_name& param_name)                \
 /**/
+#endif
 
 }
 #endif