From 86371b56956163bf6f27aa2a708c6abe28b1b1bb Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Mon, 10 Aug 2015 18:21:40 +0200 Subject: [PATCH] Fixed multiply defined symbol definition for MOCK_FUNCTION included from several translation units --- build/vc100/turtle_test.vcxproj | 3 +++ build/vc100/turtle_test.vcxproj.filters | 9 +++++++++ doc/changelog.qbk | 1 + include/turtle/mock.hpp | 8 +++++--- test/Jamfile.jam | 12 ++++++------ test/defined.hpp | 20 ++++++++++++++++++++ test/defined_1.cpp | 9 +++++++++ test/defined_2.cpp | 9 +++++++++ 8 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 test/defined.hpp create mode 100644 test/defined_1.cpp create mode 100644 test/defined_2.cpp diff --git a/build/vc100/turtle_test.vcxproj b/build/vc100/turtle_test.vcxproj index a6aed44..9de3d6d 100644 --- a/build/vc100/turtle_test.vcxproj +++ b/build/vc100/turtle_test.vcxproj @@ -19,10 +19,13 @@ + + + diff --git a/build/vc100/turtle_test.vcxproj.filters b/build/vc100/turtle_test.vcxproj.filters index 2796c51..de84e75 100644 --- a/build/vc100/turtle_test.vcxproj.filters +++ b/build/vc100/turtle_test.vcxproj.filters @@ -16,6 +16,9 @@ Source Files + + Source Files + @@ -66,5 +69,11 @@ Source Files + + Source Files + + + Source Files + \ No newline at end of file diff --git a/doc/changelog.qbk b/doc/changelog.qbk index 87bec51..5385128 100644 --- a/doc/changelog.qbk +++ b/doc/changelog.qbk @@ -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] diff --git a/include/turtle/mock.hpp b/include/turtle/mock.hpp index 9f27d0a..b7c9f65 100644 --- a/include/turtle/mock.hpp +++ b/include/turtle/mock.hpp @@ -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) diff --git a/test/Jamfile.jam b/test/Jamfile.jam index 8bc7a52..3eccba2 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -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 : : : MOCK_MAX_ARGS=21 : $(name)_max_args ; - run $(name) undefined.cpp /boost//unit_test_framework : : : MOCK_USE_CONVERSIONS : $(name)_use_conversions ; - run $(name) undefined.cpp /boost//unit_test_framework : : : MOCK_NO_DECLTYPE : $(name)_no_decltype ; - run $(name) undefined.cpp /boost//unit_test_framework : : : MOCK_NO_VARIADIC_MACROS : $(name)_no_variadic_macros ; - run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : MOCK_THREAD_SAFE BOOST_THREAD_USES_MOVE 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 : : : MOCK_MAX_ARGS=21 : $(name)_max_args ; + run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : MOCK_USE_CONVERSIONS : $(name)_use_conversions ; + run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : MOCK_NO_DECLTYPE : $(name)_no_decltype ; + run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : MOCK_NO_VARIADIC_MACROS : $(name)_no_variadic_macros ; + run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework /boost//thread : : : MOCK_THREAD_SAFE BOOST_THREAD_USES_MOVE multi : $(name)_thread_safe ; } rule run-tests diff --git a/test/defined.hpp b/test/defined.hpp new file mode 100644 index 0000000..e0587f6 --- /dev/null +++ b/test/defined.hpp @@ -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 + +MOCK_FUNCTION( f, 0, void(), f ) + +#endif // MOCK_TEST_DEFINED_HPP_INCLUDED diff --git a/test/defined_1.cpp b/test/defined_1.cpp new file mode 100644 index 0000000..7c66fd1 --- /dev/null +++ b/test/defined_1.cpp @@ -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" diff --git a/test/defined_2.cpp b/test/defined_2.cpp new file mode 100644 index 0000000..7c66fd1 --- /dev/null +++ b/test/defined_2.cpp @@ -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"