Fixed multiply defined symbol definition for MOCK_FUNCTION included from several translation units

This commit is contained in:
Mathieu Champlon 2015-08-10 18:21:40 +02:00
parent fc8c6bde19
commit 86371b5695
8 changed files with 62 additions and 9 deletions

View file

@ -19,10 +19,13 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\test\defined.hpp" />
<ClInclude Include="..\..\test\mock_error.hpp" />
<ClInclude Include="..\..\test\undefined.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\test\defined_1.cpp" />
<ClCompile Include="..\..\test\defined_2.cpp" />
<ClCompile Include="..\..\test\detail\test_function.cpp" />
<ClCompile Include="..\..\test\detail\test_invocation.cpp" />
<ClCompile Include="..\..\test\detail\test_is_functor.cpp" />

View file

@ -16,6 +16,9 @@
<ClInclude Include="..\..\test\undefined.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\test\defined.hpp">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\test\test_constraints.cpp">
@ -66,5 +69,11 @@
<ClCompile Include="..\..\test\test_exception.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\test\defined_1.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\test\defined_2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -12,6 +12,7 @@ Not yet released
* Fixed missing thread synchronization in mock::sequence
* Fixed build errors with Boost 1.59
* Fixed multiply defined symbol definition for MOCK_FUNCTION included from several translation units
[endsect]

View file

@ -163,7 +163,7 @@
#define MOCK_FUNCTION_AUX(F, n, S, t, s, tpn) \
MOCK_FUNCTION_HELPER(S, t, s, tpn) \
s inline MOCK_DECL(F, n, S,,tpn) \
s MOCK_DECL(F, n, S,,tpn) \
{ \
BOOST_MPL_ASSERT_RELATION( n, ==, \
boost::function_types::function_arity< \
@ -210,7 +210,8 @@
#define MOCK_FUNCTION(F, n, ...) \
MOCK_FUNCTION_AUX(F, n, \
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F),,)
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F), \
inline,)
#define MOCK_STATIC_METHOD(F, n, ...) \
MOCK_FUNCTION_AUX(F, n, \
@ -231,10 +232,11 @@
MOCK_METHOD_EXT(M, n, M##_sig_type, M)
#define MOCK_FUNCTION(F, n, S, t) \
MOCK_FUNCTION_AUX(F, n, S, t,,)
MOCK_FUNCTION_AUX(F, n, S, t, inline,)
#define MOCK_STATIC_METHOD(F, n, S, t) \
MOCK_FUNCTION_AUX(F, n, S, t, static,)
#define MOCK_STATIC_METHOD_TPL(F, n, S, t) \
MOCK_FUNCTION_AUX(F, n, S, t, static, typename)

View file

@ -25,12 +25,12 @@ alias mock_inspect :
rule run-test ( name )
{
run $(name) undefined.cpp /boost//unit_test_framework : : : : $(name)_ ;
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_MAX_ARGS=21 : $(name)_max_args ;
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_USE_CONVERSIONS : $(name)_use_conversions ;
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_NO_DECLTYPE : $(name)_no_decltype ;
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_NO_VARIADIC_MACROS : $(name)_no_variadic_macros ;
run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : <define>MOCK_THREAD_SAFE <define>BOOST_THREAD_USES_MOVE <threading>multi : $(name)_thread_safe ;
run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : : $(name)_ ;
run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : <define>MOCK_MAX_ARGS=21 : $(name)_max_args ;
run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : <define>MOCK_USE_CONVERSIONS : $(name)_use_conversions ;
run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : <define>MOCK_NO_DECLTYPE : $(name)_no_decltype ;
run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : <define>MOCK_NO_VARIADIC_MACROS : $(name)_no_variadic_macros ;
run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework /boost//thread : : : <define>MOCK_THREAD_SAFE <define>BOOST_THREAD_USES_MOVE <threading>multi : $(name)_thread_safe ;
}
rule run-tests

20
test/defined.hpp Normal file
View file

@ -0,0 +1,20 @@
// http://turtle.sourceforge.net
//
// Copyright Mathieu Champlon 2015
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef MOCK_TEST_DEFINED_HPP_INCLUDED
#define MOCK_TEST_DEFINED_HPP_INCLUDED
#ifdef BOOST_AUTO_TEST_MAIN
#undef BOOST_AUTO_TEST_MAIN
#endif
#include <turtle/mock.hpp>
MOCK_FUNCTION( f, 0, void(), f )
#endif // MOCK_TEST_DEFINED_HPP_INCLUDED

9
test/defined_1.cpp Normal file
View file

@ -0,0 +1,9 @@
// http://turtle.sourceforge.net
//
// Copyright Mathieu Champlon 2015
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "defined.hpp"

9
test/defined_2.cpp Normal file
View file

@ -0,0 +1,9 @@
// http://turtle.sourceforge.net
//
// Copyright Mathieu Champlon 2015
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "defined.hpp"