Commit 97fea3fd authored by Dominik Charousset's avatar Dominik Charousset

Fix handling of multimap and of local bindings

parent e3e459fa
...@@ -26,16 +26,12 @@ ...@@ -26,16 +26,12 @@
#ifdef __has_include #ifdef __has_include
# if __has_include(<optional>) # if __has_include(<optional>)
# include <optional> # include <optional>
# if __cpp_lib_optional >= 201606
# define CAF_HAS_STD_OPTIONAL # define CAF_HAS_STD_OPTIONAL
# endif # endif
# endif
# if __has_include(<variant>) # if __has_include(<variant>)
# include <variant> # include <variant>
# if __cpp_lib_variant >= 201606
# define CAF_HAS_STD_VARIANT # define CAF_HAS_STD_VARIANT
# endif # endif
# endif
#endif #endif
#include "caf/allowed_unsafe_message_type.hpp" #include "caf/allowed_unsafe_message_type.hpp"
...@@ -167,11 +163,15 @@ bool load_value(Inspector& f, T& x, inspector_access_type::map) { ...@@ -167,11 +163,15 @@ bool load_value(Inspector& f, T& x, inspector_access_type::map) {
&& load_value(f, val) // && load_value(f, val) //
&& f.end_key_value_pair())) && f.end_key_value_pair()))
return false; return false;
if (!x.emplace(std::move(key), std::move(val)).second) { // A multimap returns an iterator, a regular map returns a pair.
auto emplace_result = x.emplace(std::move(key), std::move(val));
if constexpr (is_pair<decltype(emplace_result)>::value) {
if (!emplace_result.second) {
f.emplace_error(sec::runtime_error, "multiple key definitions"); f.emplace_error(sec::runtime_error, "multiple key definitions");
return false; return false;
} }
} }
}
return f.end_associative_array(); return f.end_associative_array();
} }
......
...@@ -546,29 +546,28 @@ using caf_test_case_auto_fixture = caf::test::dummy_fixture; ...@@ -546,29 +546,28 @@ using caf_test_case_auto_fixture = caf::test::dummy_fixture;
} while (false) } while (false)
#define CAF_CHECK(...) \ #define CAF_CHECK(...) \
([&] { \ ([](bool expr_result) { \
auto caf_check_res \ auto caf_check_res \
= ::caf::test::detail::check(::caf::test::engine::current_test(), \ = ::caf::test::detail::check(::caf::test::engine::current_test(), \
__FILE__, __LINE__, #__VA_ARGS__, false, \ __FILE__, __LINE__, #__VA_ARGS__, false, \
static_cast<bool>(__VA_ARGS__)); \ expr_result); \
::caf::test::engine::last_check_file(__FILE__); \ ::caf::test::engine::last_check_file(__FILE__); \
::caf::test::engine::last_check_line(__LINE__); \ ::caf::test::engine::last_check_line(__LINE__); \
return caf_check_res; \ return caf_check_res; \
})() })(static_cast<bool>(__VA_ARGS__))
#define CAF_CHECK_FUNC(func, x_expr, y_expr) \ #define CAF_CHECK_FUNC(func, x_expr, y_expr) \
([&] { \ ([](auto&& x_val, auto&& y_val) { \
func comparator; \ func comparator; \
auto&& x_val___ = x_expr; \ auto caf_check_res \
auto&& y_val___ = y_expr; \ = ::caf::test::detail::check(::caf::test::engine::current_test(), \
auto caf_check_res = ::caf::test::detail::check( \ __FILE__, __LINE__, \
::caf::test::engine::current_test(), __FILE__, __LINE__, \
CAF_FUNC_EXPR(func, x_expr, y_expr), false, \ CAF_FUNC_EXPR(func, x_expr, y_expr), false, \
comparator(x_val___, y_val___), x_val___, y_val___); \ comparator(x_val, y_val), x_val, y_val); \
::caf::test::engine::last_check_file(__FILE__); \ ::caf::test::engine::last_check_file(__FILE__); \
::caf::test::engine::last_check_line(__LINE__); \ ::caf::test::engine::last_check_line(__LINE__); \
return caf_check_res; \ return caf_check_res; \
})() })(x_expr, y_expr)
#define CAF_CHECK_FAIL(...) \ #define CAF_CHECK_FAIL(...) \
do { \ do { \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment